Graphics Programs Reference
In-Depth Information
BNRItem s were saved. (If they were not, double-check the NSCoding implementations
in BNRItem.m .)
While you cannot load these BNRItem s back into the application yet, you can still verify
that something was saved. In Finder , hit Command-Shift-G. Then, type in ~/Library/
Application Support/iPhone Simulator and hit return. This is where all of
the applications and their sandboxes are stored for the simulator.
Open the directory 5.0 (or, if you are working with another version of iOS, select that
directory). Open Applications to see the list of every application that has run on your
simulator using iOS 5.0. Unfortunately, these applications have really unhelpful names.
You have to dig into each directory to find the one that contains Homepwner .
Figure 14.4 Homepwner's sandbox
In Homepwner 's directory, navigate into the Documents directory ( Figure 14.4 ) . You
will see the items.archive file. Here's a tip: make an alias to the iPhone Simu-
lator directory somewhere convenient to make it easy to check the sandboxes of your
applications.
Now let's turn to loading these files. To load BNRItem s when the application launches,
you will use the class NSKeyedUnarchiver when the BNRItemStore is created. In
BNRItemStore.m , add the following code to init .
- (id)init
{
self = [super init];
if (self) {
allItems = [[NSMutableArray alloc] init];
NSString *path = [self itemArchivePath];
allItems = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
// If the array hadn't been saved previously, create a new empty one
if (!allItems)
allItems = [[NSMutableArray alloc] init];
}
return self;
}
 
Search WWH ::




Custom Search