我的应用程序包中有一个configfile1.plist
文件,其中包含应用程序 UI 所需的所有设置,即背景图像、动画、声音、数据库和其他任何内容。我使用了一个 ConfigFileManager 类,其中有如下方法:
-(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"];
.
.
.
}
这是应用程序打开时在应用程序委托中调用该方法的应用程序的默认配置。现在假设我有configfile2.plist
,configfile3.plist
等等。我也有一个UIViewController
,它必须在表格视图中显示可用的配置文件。我应该怎么做,以便用户可以选择其中一个配置文件,并将其应用于整个应用程序?
任何详细的答复将不胜感激。提前致谢!