|
Core Data OverviewWhat is Core Data?The Core Data framework provides generalized and automated solutions to common tasks associated with object life-cycle and object graph management, including persistence. Its features include:
PrerequisitesCore 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:
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). Path to SuccessThe 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:
When specific areas need greater explanation, refer to the Core Data Programming Guide. Do not attempt the NSPersistentDocument Core Data Tutorial unless or until you also understand Cocoa bindings. Next StepsAfter 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 Model Object Implementation Guide and 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 and Cocoa BindingsCocoa bindings is a technology you can use to easily keep user interface elements synchronized with the data values they display. For more about Cocoa bindings, see Cocoa Bindings Programming Topics—in particular What Are Cocoa Bindings?. Cocoa bindings and Core Data are orthogonal—where Core Data is used to manage an object graph of model objects, Cocoa bindings is used to synchronize the values in an object graph with elements in a user interface. Neither technology depends on the other. Although Cocoa bindings and Core Data are independent and address different issues, both provide abstraction layers that—while individually they are reasonably straightforward to grasp—can be challenging to master simultaneously. You should choose one to learn first, then turn to the other. Once you are comfortable with bindings, watch the ADC video Core Data Tutorial and work through the NSPersistentDocument Core Data Tutorial—these bring both technologies together. There are a few isolated cases where Core Data and bindings affect one another, which are evident from their respective APIs (for example, controllers have a binding for a managed object context, and an attribute for an entity name). These points of integration should be investigated first when problems arise (see Core Data and Cocoa Bindings in Core Data Programming Guide for more information). Core Data in DepthThere 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:
|
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-03-04)
|