Graphics Programs Reference
In-Depth Information
Updating BNRItemStore
The portal through which you talk to the database is the
NSManagedObjectContext
.
The
NSManagedObjectContext
uses an
NSPersistentStoreCoordinator
.
You ask the persistent store coordinator to open a SQLite database at a particular file-
name. The persistent store coordinator uses the model file in the form of an instance of
NSManagedObjectModel
. In
Homepwner
, these objects will work with the
BNRItemStore
. These relationships are shown in
Figure 16.11
.
Figure 16.11 BNRItemStore and NSManagedObjectContext
In
BNRItemStore.h
, import Core Data and add three instance variables.
#import <CoreData/CoreData.h>
@class BNRItem;
@interface BNRItemStore : NSObject
{
NSMutableArray *allItems;
NSMutableArray *allAssetTypes;
NSManagedObjectContext *context;
NSManagedObjectModel *model;
}
In
BNRItemStore.m
, change the implementation of
itemArchivePath
to return a
different path that Core Data will use to save data.
- (NSString *)itemArchivePath
{