NSUserDefaults无法保存数据
2011-10-29 16:54
405 查看
需要 synchronize一下
参考资料:http://stackoverflow.com/questions/2622754/why-is-nsuserdefaults-not-saving-my-values/2622940#2622940
If you terminate your app by pressing the home button (in the Simulator or on the device), your User Defaults will get saved.
If you terminate your app by pressing "Stop" in Xcode (in the Simulator or on the device), your User Defaults might get saved, but there's a good chance they won't. NSUserDefaults persists any changes periodically, and if you terminate the process before they've been persisted, they'll be gone. You can force the save by calling:
参考资料:http://stackoverflow.com/questions/2622754/why-is-nsuserdefaults-not-saving-my-values/2622940#2622940
If you terminate your app by pressing the home button (in the Simulator or on the device), your User Defaults will get saved.
If you terminate your app by pressing "Stop" in Xcode (in the Simulator or on the device), your User Defaults might get saved, but there's a good chance they won't. NSUserDefaults persists any changes periodically, and if you terminate the process before they've been persisted, they'll be gone. You can force the save by calling:
[[NSUserDefaults standardUserDefaults] synchronize];
相关文章推荐
- NSUserDefaults无法保存数据
- NSUserDefaults 数据保存
- iOS NSUserDefaults数据保存报错:Attempt to set a non-property-list object...
- IOS使用NSUserDefaults保存用户登录数据时注意事项
- NSUserDefaults保存的数据 synchornize
- 用系统NSUserDefaults方法保存历史数据
- 使用NSUserDefaults对iSO应用保存设置数据和缓存对象
- 用系统NSUserDefaults方法保存历史数据
- NSUserDefaults偶尔/有时候保存数据会失败/失效
- OC数据储存本地(一)-----iOS----NSUserDefaults 保存 清空
- 【已解决】NSUserDefaults偶尔/有时候保存数据会失败/失效
- 使用NSUserDefaults保存、取出和更新数据
- iOS 数据持久化之NSUserDefaults-保存Settings
- NSUserDefaults:通常用来保存一些小巧的数据,如用户的用户名密码,或者是用户的使用习惯,如是否自动打开背景音乐等。
- NSUserDefaults保存的数据
- 关于NSUserDefaults保存数据的问题总结
- iPhone NSUserDefaults 保存数据
- NSUserDefaults保存的数据
- AppDelegate存储全局变量和 NSUserDefaults standardUserDefaults 通过模型保存和读取数据,存储自定义的对象
- Swift NSUserDefaults本地数据保存