Skip to content

Instantly share code, notes, and snippets.

@quellish
Created August 31, 2014 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quellish/4f59680cc0a679a67128 to your computer and use it in GitHub Desktop.
Save quellish/4f59680cc0a679a67128 to your computer and use it in GitHub Desktop.
2441856
// In your answer, you have this:
NSManagedObjectID *objectID = [person objectID];
dispatch_async(dispatch_get_main_queue(), ^{
//update your UI here
Person *thePerson = (Person *)[[delegate managedObjectContext] objectWithID:objectID];
self.myUIElement.text = person.firstname;
});
//Change to:
NSString *firstName = person.firstname;
dispatch_async(dispatch_get_main_queue(), ^{
//update your UI here
self.myUIElement.text = firstName;
});
// Safe!
// Less complexity!
// No need to do ANY core data operations on the UI thread!
// Does not need to assume anything about [delegate managedObjectContext]!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment