views:

299

answers:

1

Hi all,

I'm using [NSUserDefaults standardUserDefaults] for storing application settings.

My questions are:

  • do those settings are removed on app deletion?
  • are they kept after an application update (through the AppStore)?

Because I'm using it to store a password and don't want my users to reset them at each update. Also, I'd like that the only way to reset the password would be to remove the app and re-install it.

Is NSUserDefault the right choice?

Thanks, Jérémy

+4  A: 

Yes, they are removed on app deletion and yes they are kept when an application is updated.

However, you're not advised to store sensitive data in the NSUserDefaults, instead I would look at using the Keychain.

Tom Irving
Thank you Tom! Exactly the kind of response I needed.
jchatard
Not a problem :)
Tom Irving
Hi Tom and jchatard, thanks for your post, it helps me also. However if I want to store the data even when the app is deleted, is there anyway? Like using plist? My situation is to store the info of whether the user has in-app purchased items. Obviously I don't want to charge them again if they remove and reinstall the app. Or is it done by the app store to remember their purchase history at their iTunes account? Thanks.
Anthony Chan
When an app is deleted, ALL its data is deleted along with it. I don't know whether or not the store remembers what a user has purchased.
Tom Irving