-
Notifications
You must be signed in to change notification settings - Fork 123
Open
Description
The iCloud and CoreData Article is in fact pretty good but for me there was one thing missing.
I wondered how to figure out when to update the UI when an App is first launched and the iCloud Store is filled with data.
I tought listening for the Notification in storesWillChange: would be enough.
In fact you need to update when the storeDidChange: like this (otherwise the managedObjectContext would still be different to the iCloud content):
- (void)storesDidChange:(NSNotification *)note {
//check if iCloud is imported
NSNumber *storeVal = [note.userInfo objectForKey:NSPersistentStoreUbiquitousTransitionTypeKey];
if (storeVal.integerValue == NSPersistentStoreUbiquitousTransitionTypeInitialImportCompleted) {
NSLog(@"On iCloud Store now");
//ensure that the UI will be updated d on the mainthread for UI threadsafety otherwise
//this will cause a lot of trouble...
dispatch_async(dispatch_get_main_queue(), ^{
//update UI });
}
}
I'm not sure if this was the focus of the article or I didn't read it carefully enough but maybe it's worth a consideration.
Metadata
Metadata
Assignees
Labels
No labels