【发布时间】:2011-12-03 20:50:46
【问题描述】:
可能重复:
Is there anyway to set values in the settings.bundle from within the APP
我正在开发一个 iPhone 应用程序,它会在某些时候提示用户提醒他们某个设置已关闭。从那里他们可以选择启用它并继续。我能够获取设置并在我的代码中使用,问题是以编程方式更改它们。这就是我所拥有的
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 1){
// Get the application defaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"YES" forKey:@"enabledAutoCheck"];
// Set the new settings and save
[defaults registerDefaults:appDefaults];
[defaults synchronize];
}
}
我在做一个疯狂的猜测(因为我 3 天前才开始学习 Objective-C 和 iPhone 开发!)这与设置默认设置的事实有关,这意味着它们仅在没有的情况下使用进行了先前的设置。
这只是遗漏了一些东西,还是有其他方法可以在初始设置后更改设置?
谢谢
【问题讨论】:
标签: iphone ios cocoa-touch cocoa