I have an ios application, and lately I have been receiving messages from users about their settings, getting reset. Settings are saved using NSUserDefaults .
My question is, can the default user get corrupt / reset for some reason?
A few notes on how I use it:
When I launch my application, I save the default values ββonly if the keys do not exist with registerDefaults (this is done in order to take care of the "first install" scenario).
Most of the above reports describe the failure of the application, and then when it opens again, the default settings are reset.
- My use of
NSUserDefaults pretty simple - saving numbers/strings , reading them sometimes, etc. Nothing special. I do not delete the keys.
Some sample code:
For example, I save data in different places using:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:@"FirstLevel" forKey:@"Level"]; [defaults setInteger:100 forKey:@"Score"]; [defaults synchronize];
I read using:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; int intValue = [defaults integerForKey:@"Score"]; return intValue;
So, can the default user get reset / corrupt in some way?
More generally, could this be related to the application crash message that was reported even if the crash did not occur directly as a result of writing / reading from user defaults?
source share