Skip to content

Instantly share code, notes, and snippets.

@lukeredpath
Last active December 14, 2015 15:49
Show Gist options
  • Save lukeredpath/5110534 to your computer and use it in GitHub Desktop.
Save lukeredpath/5110534 to your computer and use it in GitHub Desktop.
NSManagedObjectContext *contextOne = ...;
NSArray *objects = ...<result of fetch request on contextOne...
NSManagedObjectID *objectID = objects[0].objectID;
NSManagedObjectContext *contextTwo = ...;
id object = [contextTwo existingObjectWithID:objectID error:nil]; // returns the right object
NSAssert(![object.objectID isTemporaryID]); // passes
id otherObject = [contextTwo objectWithID:objectID]; // always returns an object, should be the right object
NSAssert(![otherObject.objectID isTemporaryID]); // fails!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment