Getting Started with Core Data
The Core Data framework supports the creation of model objects that encapsulate your application data and logic in the Model-View-Controller design pattern.
Core Data’s feature set includes:
Built-in management of undo and redo beyond basic text editing
Automatic validation of property values to ensure that individual values lie within acceptable ranges and that combinations of values make sense
Change propagation, including maintaining the consistency of relationships among objects
Grouping, filtering, and organizing data in memory and in the user interface
Automatic support for storing objects in external data repositories
Core Data is not an entry-level technology. It leverages many other Cocoa technologies and design patterns. You must understand these technologies and patterns before you can use Core Data effectively:
Objective-C, memory management, notification, and delegation.
Data modeling and the model-view-controller design pattern
The terminology used by Core Data is defined and explained in the “Object Modeling” in Cocoa Fundamentals Guide section of Concepts in Objective-C Programming. You should also ensure you understand the model-view-controller design pattern, and other related design patterns, described in the same document. Many of the ideas and patterns upon which Core Data is built derive from the relational model of database design—it is extremely helpful to have a basic understanding of this subject (see, for example, Wikipedia (Relational_model)).
You should understand the concepts described in Key-Value Observing Programming Guide, which in turn depends on concepts in Key-Value Coding Programming Guide.
One of the persistent stores provided by Core Data is based upon SQLite. If you use this store, it is useful—although not essential—to have at least a superficial understanding the SQL language. Documentation for SQLite is available from the SQLite project web site. There are numerous resources that describe the SQL language, for example Wikipedia (SQL).
Get Up and Running
The Core Data Programming Guide is primarily a reference volume. You should not simply try to read it straight through to understand Core Data.
To learn about Core Data, you should typically follow this path:
If you are an OSX developer, start by reading the overview in Core Data Basics (in Core Data Programming Guide).
If you are an iOS developer, work through Core Data Tutorial for iOS.
If you are an OSX developer, you may also find it useful to read the overview given in the introduction to Core Data Tutorial for iOS (available in the iOS Developer Library).
Work through the Core Data Utility Tutorial.
This will give you an appreciation of the different components of the framework, without the distraction of a user interface.
When specific areas need greater explanation, refer to the Core Data Programming Guide.
After you’ve worked through the introductory materials, try creating more complex applications (using, for example, two related entities). The Core Data Programming Guide will be increasingly useful as you continue your exploration, as will Predicate Programming Guide. Core Data Snippets may be helpful as you write more code.
As you progress, it is important to bear in mind that Core Data objects are still just objects, and have little influence on the user interface parts of your application simply by virtue of being Core Data objects. (In fact, the reverse is true—you may find that your user interface affects the way you structure your data.) You should practice creating Core Data applications using traditional Cocoa techniques such as target-action and delegation just as you would in a non-Core Data application.
Core Data in Depth
There are several documents that describe particular aspects of Core Data in greater depth than in the Programming Guide. You should use these documents only when you have a firm understanding of how Core Data works, and then only if and when you need to:
Core Data Model Versioning and Data Migration Programming Guide
Read this document to learn how to support versioning.
Atomic Store Programming Topics, Incremental Store Programming Notes
Read these documents to understand how to create your own type of persistent store.