Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iCloud and CoreData Article: Add section about when to Update UI #6

Open
arnoappenzeller opened this issue Mar 13, 2014 · 4 comments
Open

Comments

@arnoappenzeller
Copy link

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.

@chriseidhof
Copy link
Contributor

Thanks! And sorry for only getting back to this now. Maybe you could submit a pull request, or maybe @bcapps or @mattbischoff could have a look at this? I think it'll be nice to include!

@mbbischoff
Copy link

I'll take a look tonight.Matt

On Mon, Aug 11, 2014 at 6:38 AM, Chris Eidhof [email protected]
wrote:

Thanks! And sorry for only getting back to this now. Maybe you could submit a pull request, or maybe @bcapps or @mattbischoff could have a look at this? I think it'll be nice to include!

Reply to this email directly or view it on GitHub:
#6 (comment)

@chriseidhof
Copy link
Contributor

Ping @mattbischoff =)

@mbbischoff
Copy link

I’ll PR it. Sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants