在iPhone上保存数据的最佳方法 [英] Best way to save data on the iPhone

查看:98
本文介绍了在iPhone上保存数据的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个iPhone应用程序,需要保存我的应用程序状态(5K左右)。

I am writing an iPhone application, and need to save the state of my application (5K or so).

我主要担心的是数据在升级过程中是否持续存在。我使用的一些应用程序显然错了,我宁愿不这样做!

My main worry is data persisting across upgrades. Some of the applications I use clearly got this wrong, and I would prefer not to!

推荐答案

为了保存状态,NSUserDefaults是要走的路。我相信大多数(如果不是全部)应用程序数据实例在升级后被删除是由于AppStore上的问题。它们可能与数据格式更改有关,但如果您只使用NSUserDefaults和标准的plist-storable对象(NSString,NSDictionary,NSNumber,NSArray,NSNumber和基元),那么您应该是安全的。

To save state, NSUserDefaults is the way to go. I believe most, if not all, instances of application data being deleted after an upgrade are due to issues on the AppStore. They may be related to data-format changes, but if you use just NSUserDefaults and standard plist-storable objects (NSString, NSDictionary, NSNumber, NSArray, NSNumber, and primitives), you should be safe.

这篇关于在iPhone上保存数据的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆