NSUserDefaults standardUserDefaults objects are deleted randomly

I encounter a very strange behavior for NSUserDefaults, the problem is that the [NSUserDefaults standardUserDefaults] objects are deleted randomly!

My [NSUserDefaults standardUserDefaults] contains about 65 objects (60 small NSStrings and 3 arrays, the maximum counter of which can be 4 and 2 other arrays with a maximum number of 30..number that it was never the maximum case when faced with this problem), one of these objects is the value that checks whether the user has completed the registration step. When launching the application, sometimes NSUserDefaults will contain only 5 of these 65 objects, and the rest will be deleted from plist without appearing again, even if I restart the application, which again leads the user to the registration step !!

I am sure that I use the save function correctly

[[NSUserDefaults standardUserDefaults] setObject:@"Value" forKey:@"Key"]; [[NSUserDefaults standardUserDefaults] synchronize];

I searched google for similar behavior without finding anything that could help! Has anyone come across this behavior and what is the solution to fix it?

Thanks for any help

+4
1

, .

, , : singleton, , . setter standardUserDefaults . getter . , , . , , . , , Network . false false .

:

  • , standardUserDefaults setObject: forKey: , , NOT nil
  • , (, ..), .
  • , . Debug . ( )

, .

+4

Source: https://habr.com/ru/post/1546746/


All Articles