Adding Core Data Boilerplate Code

Before you can use any data, you have to initialize Core Data for the app. You need objects for each of the three classes shown in Figure 9-1. When you become more familiar with Core Data, this is something you will probably do in your own helper class, as described in Chapter 1 of Learning Core Data for iOS: A Hands-on Guide to Building Core Data Applications by Tim Roadley. If you know your app will use Core Data before you create the project, some of the application creation templates provided by Xcode have a check box to use Core Data.

In this chapter, you use code based on the Master–Detail Application template from Xcode. The only modifications are adding an import of CoreData.h and two #defines for the ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming 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.