开发者

iPhone: Types of persistent store

I would like to know which type of persistent store would be most appropriate in what situations, like how can I decide where to use core data, property list or 开发者_StackOverflowarchives for my iPhone application.

Thanks


It's hard to recommend a good persistent store as you've said nothing about your app's needs, but here's a general overview:

90% of the time, I would recommend Core Data. With Core Data, you define your data model in terms of types of objects, relationships, and attributes, and Core Data builds the database and takes care of saving and loading your data as needed. It takes a while to learn for the first time, but it's much more robust than any other solution I know of.

If you have special requirements (e.g. deleting thousands of objects at once, etc...) and you don't mind getting your hands a bit dirty, consider SQLite. You'll have to create the database yourself, retrieve, format, and save data yourself, handle your own migrations if your data model changes, etc...

If your needs are really minimal (e.g. persisting a single array of simple values), you can use a plist file.


Adding to igul222's anwser, if you have minimal data storage needs and the data needs to be avaialble to your application everytime you access your app, you can also store the data in NSUserDefaults. However, this will be lost if you uninstall the application.


if the data need update and seeking frequently, use Sqlite .

if the data size is small and is read only, no update action is required, use property list.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜