Reputation: 4235
I'm making an app for iOS devices. It's not my first app but it doesn't important. My app use NSUserDefaults
to store data which are using during application runtime. All works good while user wants to delete app. After this and after installing/compiling app again on same device all settings from NSUserDefaults
are removed - It's look like app is first time on this device.
The question are:
NSUserDefaults
then where to store this data?Thank you in advance.
Upvotes: 0
Views: 685
Reputation: 7924
I think you could store defaults in your custom plist, and then use iCloud, which is built in iOS. iCloud will automatically backup documents from your app, and then you have them available on new installations since apple handles this.
Have a look at apple's official documentation about storing key value data on iCloud:
In that link they explain how to add key value data on iCloud to your app.
Upvotes: 1
Reputation: 119031
You want to use the keychain, docs here.
This is the only way on the device. Possibly you could use iCloud depending on exactly what you're trying to achieve.
Upvotes: 1
Reputation: 50099
the nsuserdefaults are not preserved. nothing in your app's sandbox is BUT for the keychain. values in the keychain are not erased.
so use the keychain for values that you want to keep.
BUT don't store everything in there. normally when a user deletes an app he wants stuff gone.
the only other way I can see would be your own server where users can store backups, the dropbbox api or icloud
Upvotes: 2