[英]How to synchronize with NSUserDefaults in Settings.bundle?
I created my application settings in Settings.bundle
. 我在
Settings.bundle
创建了我的应用程序设置。 I go into the Settings App
and update a value. 我进入
Settings App
并更新值。 When I relaunch my app (which was in the background), how do I check for the updated settings in the Settings App
. 当我重新启动我的应用程序(在后台)时,如何在“
Settings App
检查更新的Settings App
。
I tried the following but I still get the old value. 我尝试了以下但我仍然得到了旧的价值。 Any suggestions?
有什么建议?
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkAutoUpdateSettingsForNotificaiton:) name:UIApplicationDidBecomeActiveNotification object:nil];
- (void)checkAutoUpdateSettingsForNotificaiton:(NSNotification *)aNotification
{
NSNumber *period = [[[NSUserDefaults standardUserDefaults] objectForKey:@"periodID"] retain];
}
I had to add [[NSUserDefaults standardUserDefaults] synchronize];
我不得不添加
[[NSUserDefaults standardUserDefaults] synchronize];
to do the synchronization. 进行同步。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.