Graphics Programs Reference
In-Depth Information
Figure 16.10 Changing the class of an entity
There is one problem: the BNRItem class already exists, and it does not inherit from
NSManagedObject . Changing the superclass of the existing BNRItem to NSMan-
agedObject will require considerable modifications. Thus, the easiest solution is to re-
move your current BNRItem class files, have Core Data generate a new BNRItem class,
and then add your behavior methods back to the new class files.
In Finder , drag both BNRItem.h and BNRItem.m to your desktop for safekeeping.
Then, in Xcode , delete these two files from the project navigator. (They will appear in red
after you have moved the files).
Now, open Homepwner.xcdatamodeld again and select the BNRItem entity. Then,
select New File... from the New menu.
From the iOS section, select Core Data , choose the NSManagedObject subclass option,
and hit Next . When prompted to save, check the box for Use scalar properties for primit-
ive data types .
Xcode will generate two new BNRItem.h and BNRItem.m files. Open BNRItem.h
and see what Core Data has wrought. Change the type of the thumbnail property to
UIImage and add the method declaration from the previous BNRItem .
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface BNRItem : NSManagedObject
@property (nonatomic, strong) NSString * itemName;
@property (nonatomic, strong) NSString * serialNumber;
@property (nonatomic) int32_t valueInDollars;
 
Search WWH ::




Custom Search