How persistent is [NSUserDefaults standardUserDefaults]?

我怕爱的太早我们不能终老 提交于 2019-12-30 06:11:13

问题


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


回答1:


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.




回答2:


I use NSUserDefaults in my app to allow additional access to my app for my colleagues. They just have to enter the code word in settings and the app is fully opened.

to the point each time I update the app they have to re-enter the code word, so I would say from experience that they are not kept after updates. The values need to be re-entered.



来源:https://stackoverflow.com/questions/3133127/how-persistent-is-nsuserdefaults-standarduserdefaults

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!