Graphics Programs Reference
In-Depth Information
The model file
In a relational database, we have something called a
table
. A table represents some type;
you can have a table of people, a table of a credit card purchases, or a table of real-estate
listings. Each table has a number of columns to hold pieces of information about that
thing. A table that represents people might have a column for the person's name, social se-
curity number, height, and age. Every row in the table represents a single person.
Figure 16.2 Role of Core Data
This organization translates well to Objective-C. Every table is like an Objective-C class.
Every column is one of the class's instance variables. Every row is an instance of that
class. Thus, Core Data's job is to move data to and from these two organizations (
Fig-
Core Data uses different terminology to describe these ideas: a table/class is called a
en-
tity
, and the columns/instance variables are called
attributes
. A Core Data model file is the
description of every entity along with its attributes in your application. In
Homepwner
,
you're going to describe a
BNRItem
entity in a model file and give it attributes like
itemName
,
serialNumber
, and
valueInDollars
.
Open
Homepwner.xcodeproj
. From the
File
menu, create a new file. Select
Core
Data
in the
iOS
section and create a new
Data Model
. Name it
Homepwner
.
Figure 16.3 Create the model File