views:

77

answers:

3

Hi,

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 archives for my iPhone application.

Thanks

+2  A: 

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.

igul222
+1  A: 

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.

Hetal Vora
A: 

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.

Robin
Using SQLite directly is never a good answer. The overhead does not justify its use. Core Data, which persists to SQLite, is the right answer except in a few very rare situations.
Marcus S. Zarra
why is never ... if the app need sync new data with remote database, I believe use sqlite is more better than coreData, coreData use 'previate' and 'un-understanding' table structures, it can not be use by other app... but if use sqlite then I think the app just need download the newest sqlite data file and replace old local sqlite file , or else the iPhone app have to be preform insert operations....
Robin
of course , coreData provide good framework to use, but in my experience it seem not perfect ... for example: if a managedObject 'Master' has a property set objects 'Details', (this case most like 'Master' and 'Details' relationship) once the managedObject was constructed, the property 'Details' seem also was constructed , consider the performance issue, I am strange that why not use 'lazy loading' ... again, I think that the coreData also does not provide good transaction management ... just a personal thought... welcome point my fault :-) thanks. Regards
Robin