您的位置:首页 > 其它

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:

[[NSUserDefaults standardUserDefaults] synchronize];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: