Data persistence through NSUserDefaults

北城以北 提交于 2019-12-19 04:19:07

问题


Is data persisted in NSUserDefaults between app launches? I want some small data to be persisted even if I quit and relaunch the app.


回答1:


Yes.

Data will persist in NSUserDefaults for the entire lifetime of the app.




回答2:


Data will persist. But, NSUserDefaults is used primarily for preferences. Users expect that it is okay to delete the preference file without affecting their documents and created data.

If the data is not a preference, you may want to store the data in a file inside ~/Library/Application Support/[your application's name]/ instead.



来源:https://stackoverflow.com/questions/4771496/data-persistence-through-nsuserdefaults

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