开发者

How to synchronize with NSUserDefaults in Settings.bundle?

开发者 https://www.devze.com 2023-03-29 22:36 出处:网络
I created my application settings in Settings.bundle. I go into the Se开发者_运维技巧ttings App and update a value. When I relaunch my app (which was in the background), how do I check for the updated

I created my application settings in Settings.bundle. I go into the Se开发者_运维技巧ttings App and update a value. When I relaunch my app (which was in the background), how do I check for the updated settings in the 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]; to do the synchronization.

0

精彩评论

暂无评论...
验证码 换一张
取 消