O'Reilly logo

iOS 7 Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.2. Generating Class Files for Core Data Entities

Problem

You followed the instructions in Recipe 18.1 and you want to know how to create code based on your object model.

Solution

Follow these steps:

  1. In Xcode, find the file with the xcdatamodel extension that was created for your application when you created the application itself in Xcode. Click the file, and you should see the editor on the righthand side of the Xcode window.

  2. Select the Person entity that we created earlier (see Recipe 18.1).

  3. Select File New File in Xcode.

  4. In the New File dialog, make sure you have selected iOS as the main category and Core Data as the subcategory. Then choose the NSManagedObject subclass item from the righthand side of the dialog and press Next, as shown in Figure 18-7.

Creating a managed object subclass in Xcode

Figure 18-7. Creating a managed object subclass in Xcode

  1. On the next screen, choose the managed object model that you want to save to disk and ensure it is ticked. Once you are done, press the Next button (see Figure 18-8).

Selecting which managed object model to save on disk

Figure 18-8. Selecting which managed object model to save on disk

Note

You will see only one managed object model in the list if you have only one model in your project. The reason we are seeing more than one model in Figure 18-8 is that my workspace in Xcode contains various projects, each with its own model.

  1. Now you will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required