Created
August 12, 2012 15:52
-
-
Save ChristianKienle/3332404 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)viewDidLoad | |
| { | |
| [super viewDidLoad]; | |
| [[NSNotificationCenter defaultCenter] addObserverForName:SISPersistentStoreNotifications.didImportUbiquitousContentChanges object:nil queue:nil usingBlock:^(NSNotification *note) { | |
| CMKUbiquitousChange *change = [note.userInfo objectForKey:@"ubiquitousChange"]; | |
| NSArray *insertedObjectIDs = change.insertedObjectIDs; | |
| NSMutableArray *insertedObjects = [NSMutableArray array]; | |
| for(NSManagedObjectID *objectID in insertedObjectIDs) | |
| { | |
| NSManagedObject *object = [self.managedObjectContext objectWithID:objectID]; | |
| if(object == nil) | |
| { | |
| continue; | |
| } | |
| [insertedObjects addObject:object]; | |
| } | |
| NSDictionary *userInfo = @{NSInsertedObjectsKey : insertedObjects}; | |
| NSNotification *didSaveNotification = [NSNotification notificationWithName:NSManagedObjectContextDidSaveNotification object:self userInfo:userInfo]; | |
| [self.managedObjectContext performBlock:^{ | |
| [self.managedObjectContext mergeChangesFromContextDidSaveNotification:didSaveNotification]; | |
| }]; | |
| }]; | |
| // Do any additional setup after loading the view, typically from a nib. | |
| self.navigationItem.leftBarButtonItem = self.editButtonItem; | |
| UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)]; | |
| self.navigationItem.rightBarButtonItem = addButton; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment