Graphics Programs Reference
In-Depth Information
}];
}
Now, in ListViewController.m , register as an observer of this notification in
initWithStyle: .
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(storeUpdated:)
name:BNRFeedStoreUpdateNotification
object:nil];
In ListViewController.m , implement storeUpdated: .
- (void)storeUpdated:(NSNotification *)note
{
[[self tableView] reloadData];
}
You could build and run the application now, but there is one more minor change to make.
Currently, the SQLite file is stored in the Documents directory of Nerdfeed 's sandbox.
This is okay except for one case: if another iCloud user logs in on this device, this user
will have the same read list as the previous user because the SQLite file is stored in a loc-
ation that is specific to the application not the iCloud user.
To make the SQLite file user-specific, we can move it into the ubiquity container but mark
it so that it will not get stored in the cloud. We can tell iCloud to ignore a file or directory
in a ubiquity container by suffixing it with .nosync . In BNRFeedStore.m , update
init to create a feed.nosync directory and put the SQLite file in that directory.
NSMutableDictionary *options = [NSMutableDictionary dictionary];
[options setObject:@"nerdfeed" forKey:NSPersistentStoreUbiquitousContentNameKey];
[options setObject:ubContainer forKey:NSPersistentStoreUbiquitousContentURLKey];
NSError *error = nil;
NSString *dbPath =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES) objectAtIndex:0];
dbPath = [dbPath stringByAppendingPathComponent:@"feed.db"];
NSURL *dbURL = [NSURL fileURLWithPath:dbPath];
// Specify a new directory and create it in the ubiquity container
NSURL *nosyncDir = [ubContainer URLByAppendingPathComponent:@"feed.nosync"];
[fm createDirectoryAtURL:nosyncDir
withIntermediateDirectories:YES
 
Search WWH ::




Custom Search