开发者

Core Data Vs File System

开发者 https://www.devze.com 2023-01-23 09:58 出处:网络
What is the difference between storing data in CORE data and storing them in File system. And on what basis should one choose bet开发者_StackOverflowween them?Core data is nice when your application d

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


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).

0

精彩评论

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