我的应用包中有一个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
,它必须在表格视图中显示可用的配置文件。我应该怎么做,以便用户可以选择一个配置文件,并将其应用于整个应用程序?
任何详细的回复将不胜感激。 提前致谢!
答案 0 :(得分:0)
一般的想法是这样的:
您已完成第1步和第2步。因此,您必须决定在何处存储选项以供日后检索。
一种选择是使用[NSUserDefaults standardUserDefaults]
保存所选选项。您可以查看InAppSettingsKit
及其示例应用,看看整个过程是如何工作的。