简体   繁体   English

如何在Settings.bundle中与NSUserDefaults同步?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM