NSUserDefaults not saved in the simulator?

Mine is [NSUserDefaults standardUserDefaults]not saved. Everything that I close the application and start it again is returned. I don’t have an iOS device, so I'm not sure if this will happen on the device, but none of the other applications do this in the simulator, which makes me believe that something is wrong with my code. I don’t know what part of the code I should include here, just just add / change keys in nsuserdefaults, and as I said, it works fine during the application, but not after I restarted it ...

I know I can call synchronize, but Apple advises against him and says that I should only call him if he should ... like that.

What could be wrong? Thank.

+3
source share
3 answers

Your process may not have completed correctly, so NSUserDefaults do not have the ability to be saved. See also this one and basically.

The proposal in the second post, to which I refer - is to call synchronizeinapplicationDidEnterBackground:

Keep in mind that terminating your application by stopping it in Xcode most often does not save user defaults.

+8
source

Are you restarting from Xcode / debugger? Try sending the app to the background image first using the Home button. I think the framework will automatically sync.

0
source

, NSUserDefault, , sharedDefaults, NSUserDefault Apple

NSUserDefault

[NSUserDefaults standardUserDefaults];

Read the blog for more details NSUserDefault.

IPhone Programming Tutorial - Saving / Retrieving Data Using NSUserDefaults

0
source

All Articles