I am trying to save my NSUserDefaults when the viewWillDisappear is called on one of my subviews. I can confirm it is getting called.
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"test" forKey:@"123"];
[defaults synchronize];
However whenever I restart the app and try to use it:
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey@"test"])
NSLog(@"did not exist");
else
NSLog(@"found it");
it never finds it. Why?
You are swapping your key and object. It should be: