This is weird, and I hope it only is occurring in debug mode. But I have a string saved in user defaults. And I'm noticing every so often user defaults is returning nil. And it is making my app act weird. I just caught the problem like this:
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *code = [userDefaults stringForKey:KEY_HERE];
if (code == nil)
{
return YES;
}
return NO;
}
Now....I close the last window several times, and the string does get returned. But I noticed after awhile, stringForKey: returns nil out of nowhere and my app terminates. Then on next launch, stringForKey: returns the actual value again (not nil). Is there a known cause for this?