Chapter 12. Core Data

12.0. Introduction

Core Data is a powerful framework on the iOS SDK that allows programmers to store and manage data in an object-oriented way. Traditionally, programmers had to store their data on disk using the archiving capabilities of Objective-C or write their data to files and manage them manually. With the introduction of Core Data, programmers can simply interact with its object-oriented interface to manage their data efficiently. In this chapter, you will learn how to use Core Data to create the model of your application (in the Model-View-Controller software architecture).

Core Data interacts with a persistent store at a lower level that is not visible to the programmer. iOS decides how the low-level data management is implemented. All the programmer must know is the high-level API she is provided with. But understanding the structure of Core Data and how it works internally is very important. Let’s create a Core Data application to understand this a bit better.

Core Data in an iOS application needs a bit of setting up. Fortunately, with Xcode, this process is very easy. You can simply create a Core Data application and leave the rest up to Xcode.

Follow these steps to create an application in Xcode to take advantage of Core Data:

  1. In Xcode, choose FileNewNew Project.

  2. Choose iOS Application as the template.

  3. Choose Window-based Application as the template object.

  4. Choose Universal in the Product drop-down menu and make sure you choose “Use Core Data for storage,” ...

Get iOS 4 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.