iOS Reference Library Apple Developer
Search

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.

Important: This document describes the features of the data modeling tool and how to use it. It does not explain the basic features and functionality of the Core Data framework. You must read the introductory material in Core Data Programming Guide before reading this chapter or attempting to use the data modeling tool. For more about specific Core Data classes, see the relevant API reference documentation.

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, it is possible to 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. (Note that a model does have a constraint not shared with a nib file: once loaded, a model cannot be modified after it has been used.)

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 the mapping model using Xcode’s mapping model tool.

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:




Last updated: 2009-03-02

Did this document help you? Yes It's good, but... Not helpful...