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

Chapter 18. Core Data

18.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.

With the new LLVM compiler, all you have to do in order to include Core Data into your project is to include the umbrella header file, like so:

#import "AppDelegate.h"
#import <CoreData/CoreData.h>

@implementation AppDelegate

<# Rest of your code goes here #>

To be able to work with Core Data, you need to understand that a Core Data stack is based on the following concepts:

Persistent store

The object that represents the actual data base on disk. We never use this object directly.

Persistent store ...

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