Working with data in iOS Apps (What to choose? NSData, CoreData, sqlite, PList, NSUserDefaults) Working with data in iOS Apps (What to choose? NSData, CoreData, sqlite, PList, NSUserDefaults) sqlite sqlite

Working with data in iOS Apps (What to choose? NSData, CoreData, sqlite, PList, NSUserDefaults)


You can use these rules of thumb to decide what storage model will work for your app.

  • If the data fits in memory entirely and is relatively unstructured, use plist
  • If the data fits in memory entirely and has tree-like structure, use XML
  • If the data does not fit in memory and has a structure of a graph, and the app does not need extraordinary query capabilities, use Core Data
  • If the data does not fit in memory, has a complex structure, or the app benefits from powerful query capabilities provided by relational databases, use sqlite
  • If the data must be secret (e.g. a password), use keychain.

Note that these choices often overlap, because multiple storage models will fit the same app. Your final decision depends on your personal preferences - you pick a technology that you understand better.

There was a very good question about sqlite vs. Core Data on Stack Overflow, you may want to read through the answers to that question.


My rule of thumb for each of those would be:

  • Time Tracker App > Core Data
  • RSS Reader App > Core Data
  • Photo App > Core Data
  • EMail Client > Core Data

Though in each case there would be things you would store on the file system. For instance, the photo app would obviously put the actual photos on the file system. The text of the emails would be on the file system etc. The actual RSS messages might be text files too, but with meta data in Core Data objects.

At some point, you might find that the data you are storing is outgrowing the scalability of Core Data. At that point you would consider moving to SQLite.

The point is that Core Data is so easy to use and so superior to the alleged lighter weight alternatives, why wouldn't you use it?