I get some error messages in logs
[User Defaults] Failed to write value for key GameId in CFPrefsPlistSource<0x1740faf00> (Domain: xxx.xxxxxx, User
I'd like to share my solution for this problem. For my case, the error was a legitimate error and my data was not saved properly. It turns out the error was caused by having a NSUserDefaults "data saving" in a loop.
By "data saving" I mean this (pseudocode):
loop{
[defaults setObject:@"Data" forKey:@"Key"];
[defaults synchronize];
}
So the code executes this multiple times very fast and cause the problem. I guess "synchronize" cannot handle concurrent calls.
What needs to be done is:
loop{
[defaults setObject:@"Data" forKey:@"Key"];
}
[defaults synchronize];
synchronize be called once after all the objects been set.