Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data Vs File System

Tags:

iphone

What is the difference between storing data in CORE data and storing them in File system. And on what basis should one choose between them?

like image 669
Abhinav Avatar asked Dec 12 '22 18:12

Abhinav


1 Answers

Core data is nice when your application data is very structured, whereas just serializing things to the file system is useful when you are just shuffling around semi-structured data (e.g., an NSDictionary with some arbitrary keys and values).

Another advantage of Core Data is that you can (when using the NSSQLiteStoreType store type) store (and efficiently query) more data that can fit in the device's memory, which is something that would be a challenge to do with manually serialized objects.

So in short I would recommend Core Data if any of the following are true:

  1. You might have more data than can fix comfortably in the device's memory
  2. You need to efficiently query the data
  3. Your data is well-structured

I would recommend using serialized data really only when you have small amounts loosely-structured data, such as a dictionary of user preferences.

In any case, you should take the Core Data tutorials if you haven't already. Even if you don't wind up using Core Data, it is very useful to understand the concepts for other reasons (e.g., because it ties into the Undo/Redo system).

like image 193
marcprux Avatar answered Dec 29 '22 13:12

marcprux