Graphics Programs Reference
In-Depth Information
YES) objectAtIndex:0];
dbPath = [dbPath stringByAppendingPathComponent:@"feed.db"];
NSURL *dbURL = [NSURL fileURLWithPath:dbPath];
if (![psc addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:dbURL
options:nil
error:&error]) {
[NSException raise:@"Open failed"
format:@"Reason: %@", [error localizedDescription]];
}
// Set up the persistent store with the transaction log details
if (![psc addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:dbURL
options:options
error:&error]) {
[NSException raise:@"Open failed"
format:@"Reason: %@", [error localizedDescription]];
}
context = [[NSManagedObjectContext alloc] init];
[context setPersistentStoreCoordinator:psc];
[context setUndoManager:nil];
}
return self;
}
Build the application to check for syntax errors, but don't run it quite yet.
Notice here that you created an NSURL instance with URLForUbiquityContainer-
Identifier: . This method of NSFileManager returns the location of the ubiquity
container on the device. The argument passed to this method is a container identifier
string. While you could pass the container identifier string you set up in the previous sec-
tion, it is easier to pass nil . Passing nil automatically constructs the container identifier
using the application's bundle identifier, in our case,
com.bignerdranch.Nerdfeed . (Technically, you have to pass a slightly different
string. There's more about this in the section called “For the More Curious: iCloud
Backups” . )
Next, a dictionary is created with two key-value pairs. The first key, NSPersist-
entStoreUbiquitousContentNameKey , is the name of the transaction log in the
ubiquity container. This name must be unique within the ubiquity container. It is used in
conjunction with the NSPersistentStoreUbiquitousContentURLKey that
identifies the location on the filesystem of the ubiquity container. In simple terms, it cre-
ates a transaction log file named nerdfeed in the directory that ubContainer repres-
 
Search WWH ::




Custom Search