How to synchronize with NSUserDefaults in Settings.bundle?
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.
精彩评论