1

I have a configfile1.plist file in my app bundle that includes all the required settings for the UI of the app, i.e. the background images, the animations, the sounds, database, and anything else. I have used a ConfigFileManager class in which there's this method as follows:

-(void) loadConfigFile
{
    configFile = [[NSBundle  mainBundle] pathForResource:@"ConfigFile1"
                                              ofType:@"plist"];
rootDictionary = [[NSDictionary alloc]initWithContentsOfFile:configFile];

//__ settings
settings = [rootDictionary objectForKey:@"settings"];
timerMode = [settings objectForKey:@"timerMode"];
timePerQuestion = [settings objectForKey:@"timePerQuestion"];
if (timerMode.intValue == 1) {
    //__time is fixed.
}
else
{
    //time is not fixed, there's an initialTime to begin with, and it increases if the answer is correct (timePerQuestion), and doesn't change if it's wrong.
    initialTime = [settings objectForKey:@"initialTime"];
}

//__ Textures
textures = [rootDictionary objectForKey:@"textures"];

//__ buttons
buttons = [textures objectForKey:@"buttons"];
buttonBackground = [buttons objectForKey:@"buttonBG"];
buttonBackgroundSelected = [buttons objectForKey:@"buttonBGSelected"];
mainMenuPlayButton = [buttons objectForKey:@"mainMenu.playButton"];
.
.
.
}

This is the default configuration for the app for which the method is called in the app delegate while the app is being opened. Now let's say I have configfile2.plist, configfile3.plist, and so on. I have a UIViewController for this, too, that must display the available config files in a table view. What should I do this, so that the user can select one of the config files, and that gets applied to the whole app?

Any detailed response will be appreciated. Thanks in advance!

Neeku
  • 3,646
  • 8
  • 33
  • 43

1 Answers1

0

The general idea is like this:

  1. a .plist stores possible options
  2. shows the options to user
  3. save the selected options to somewhere
  4. refresh UI based on saved options

You have done step 1 and 2. So you have to decide where to store the options for later retrieval.

One option is to use [NSUserDefaults standardUserDefaults] to save selected options. You may check out InAppSettingsKit and its sample app to see how the whole thing work.

ohho
  • 50,879
  • 75
  • 256
  • 383