15.1. Creating a Core Data Model with Xcode


You want to visually design the data model of your iOS application using Xcode.


Follow the instructions in this chapter’s Introduction to create a Core Data project. Then find the file with the extension of xcdatamodel in your application bundle in Xcode and click on it to open the visual data editor, as shown in Figure 15-4.

Visual data editor in Xcode

Figure 15-4. Visual data editor in Xcode


Xcode’s visual data editor is a fantastic tool that allows programmers to design the data model of their applications with ease. There are two important definitions you need to learn before you can work with this tool:


Corresponds to a table in a database.


Corresponds to a column in a table.

Entities will later become objects (managed objects) when we generate the code based on our object model. This is explained in Recipe 15.2. For now, in this recipe, we will concentrate on creating the data model in this tool.

In the editor, find the + button at the bottom. Press and hold your mouse button on this button and then select Add Entity from the menu that will appear, as shown in Figure 15-5.

Adding a new entity to our data model

Figure 15-5. Adding a new entity to our data model

Your new entity will be created and will be in a state where you can immediately rename it after creation. Change ...

Get iOS 6 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.