You have problems with NSUserDefaults here.
This is how I create it:
NSString *theCity = @"Test City"; [[NSUserDefaults standardUserDefaults] setObject:theCity forKey:@"SavedCity"];
This is how I try to restore it:
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"SavedCity"]) { NSLog(@"Key exists! %@",[[NSUserDefaults standardUserDefaults] objectForKey:@"SavedCity"]); } else { NSLog(@"No city saved!"); }
The problem is that even if there is a key for "SavedCity" (I check the pref file in the Simulator directory), it always displays "No city saved". Am I doing something wrong?
Thanks!
source share