User Tools

Site Tools


ios-labs-s14:intermediate-stores

Persistent Stores

There are three methods of storing data to a device so that it persists through app or phone shutdowns:

  1. NSUserDefaults- a dictionary stored to the device's internal memory. Any object can be stored under given keys, but you must implement the <NSCoding> protocol for custom objects before committing them to memory
  2. CoreData- local database wrapper, backed by sqlite3. Not technically a relational database, but abstracts away a lot of configuration details
  3. Plist files- property list files, essentially dictionaries written out to files in the form of key/value pairs

They all accomplish the same task: storing items on the device's hard drive. Objects living in memory (that you alloc/init) live in RAM and will not stick around if the app crashes or is terminated.

  1. NSUserDefaults- officially to be used for “defaults” information, or saved information about the user's behavior or preferences, but in practice can handle 1000-100,000 object transactions without impacting performance. Minimal code required. Easiest to use.
  2. CoreData- efficient, optimized, and filled with shortcuts, useful for large or small data sets. Contains a system for managing the entire model in a graphical way. Requires no knowledge of databases. More difficult to setup. Can transfer database file away from app with some difficulty.
  3. Plist files- least efficient, cannot handle large transactions without impacting performance. Difficult to setup, not commonly used. Can move plist file around fairly easily, useful when including data with app without using CoreData.
ios-labs-s14/intermediate-stores.txt · Last modified: 2014/02/23 21:59 by mbarboi