You need to register the default dictionary with NSUserDefaults every time your application starts:
NSDictionary *defaultValues = [NSDictionary dictionaryWithObject:
[NSNumber numberWithBool:YES] forKey:@"myUserDefaultsKey"];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
Now,
[[NSUserDefaults standardUserDefaults] boolForKey:@"myUserDefaultsKey"];
will return YES if the key is missing.
source
share