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!