I am making an application in which i have added the settings(nsuserdefaults)
The problem is in my mainviewcontroller i declare user defaults and get its values. However since viewdidload is not called after user goes to settings and comes back to the app. My settings does not update.
I tried declaring user defaults in app delegate applicationwillenterforeground but how will i pass the message to mainviewcontroller.
variables defined in app delegate are not recognised in mainviewcontroller.
Update : I have declared
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
}
i have toggle switch in settings which has identifier enabled_preference so i wrote
else
{
[PlaySound prepareToPlay];
[prefs setBool:YES forKey:@"enabled_preference"];
BOOL loop = [prefs boolForKey:@"enabled_preference"];
NSLog(@" %d",loop);
do {
[PlaySound play];
} while (loop ==YES);
it is logging 0 in console however i have set default to yes in plist