Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Xcode Entity Modeling Tools for Core Data
The Xcode data modeling tool deals with entities and the relationships between them. You use the tool to define a schema for Core Data. The model ultimately becomes part of your build product and is used by your application at runtime.
The purpose of the Core Data data modeling tool is to create a data model (or schema) for use with the Core Data framework. At runtime, the model is turned into an instance of NSManagedObjectModel
with a collection of NSEntityDescription
, NSAttributeDescription
, NSRelationshipDescription
, and NSFetchRequest
objects. In some respects this is analogous to the behavior of Interface Builder. With Interface Builder, you graphically create a collection of objects that are then saved in a file (a nib file) and re-created at runtime. As with user interface elements, you can create a model directly in code at runtime; however, it is typically easier to do so graphically using the appropriate tool. Similarly, just as it is possible to modify the user interface after it has been loaded, it is also possible to customize a model after it has been loaded. (A model does have one constraint not shared with a nib file: a model cannot be modified after you have integrated it into the Core Data stack.)
As your application evolves, to accommodate new features you may need to change the schema. Core Data provides an infrastructure for migrating data from one schema (model version) to another—see Core Data Model Versioning and Data Migration Programming Guide. To use this infrastructure, you need to define a versioned model, and mappings between model versions. You create a versioned model using Xcode’s data modeling tool (see Model Versioning) and, if necessary, a mapping model using Xcode Mapping Tool for Core Data.
You should read this document to learn how to use the Xcode entity modeling tool to create a managed object model for a Core Data application. For a task-based example of how to create a data model, see Creating a Managed Object Model with Xcode.
Organization of This Document
This document contains the following sections:
Creating a Data Model File describes how to create a model file.
Workflow describes the basic features of the data modeling tools and how you use them.
The Browser View describes the diagram view of the data modeler.
The Diagram View describes the diagram view of the data modeler.
The Predicate Builder describes the predicate builder.
Code Generation describes how to generate source code for model entities and their properties.
Model Versioning describes how to create a versioned model and how to specify the current version in a versioned model.
Compiling a Data Model describes how to compile a data model and what compiler flags are available.
Creating a User Interface From a Data Model describes how to use the data modeler in conjunction with Interface Builder to create a user interface.
Copyright © 2010 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2010-09-02