I have a NSUserDefault BOOL value with a key @"MenuMusic". It is accessible to the user through the Settings App as a on/off switch.
When the game starts, I read in the user's prefrence with
Code:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
menuMusic = [prefs boolForKey:@"MenuMusic"];
Since os4.0 allows an application to be put in the Background and then brought back to the Foreground, I have implemented the following method
Code:
- (void)applicationWillEnterForeground:(UIApplication *)application {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
menuMusic = [prefs boolForKey:@"MenuMusic"];
}
in the hopes of being able to detect changes to the User Default settings while the app was in the background.
But it doesn't work. It keeps the setting it was originally set to, YES if it was YES and NO if it was NO.
Any ideas what I might be doing wrong. Or maybe just the correct way of updating User Settings.
As always, any help is appreciated. Thanks,
Mark
ps. or maybe I can turn off the ability to go into Enter Background.