我想加载并保存设置。我不知道我把registerDefaults放在哪里。 我把它放在loadSetting中。我想我做错了。我是否必须在申请结束时把它放在didFinishLaunch?
- (void)loadSettings {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], @"key1",
[NSNumber numberWithBool:NO], @"key2",
nil];
[defaults registerDefaults:dictionary];
key1Value = [defaults boolForKey:@"key1"];
key2Value = [defaults boolForKey:@"key2"];
}
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: NSDictionary *)launchOptions {
[self loadSettings];
}
答案 0 :(得分:0)
对我来说没问题。我想只要你在加载任何视图之前调用它,你应该没问题。