Created
August 2, 2012 23:08
-
-
Save blackgold9/3241738 to your computer and use it in GitHub Desktop.
Made this "fix" to MR_inContext
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
- (id) MR_inContext:(NSManagedObjectContext *)otherContext | |
{ | |
__block NSError *error; | |
if ([self.objectID isTemporaryID]) { | |
if (otherContext.parentContext == self.managedObjectContext) | |
{ | |
// We have a temporary id, which can never be used to lookup accross contexts, but we're trying it from a child context, so we can just get it | |
[self.managedObjectContext performBlockAndWait:^{ | |
MRLog(@"Automatically obtaining a permanent Id so we can find it in a child context"); | |
[self.managedObjectContext obtainPermanentIDsForObjects:[NSArray arrayWithObject:self] error:nil]; | |
[MagicalRecord handleErrors:error]; | |
error = nil; | |
}]; | |
} else { | |
MRLog(@"Unable to obtain a permanent Id for object. [NSManagedObject MR_inContext:] will not succeed"); | |
} | |
} | |
NSManagedObject *inContext = [otherContext existingObjectWithID:[self objectID] error:&error]; | |
[MagicalRecord handleErrors:error]; | |
return inContext; | |
} |
you mean, people will just use code without understanding how and why it works?
Yup
…Sent from my mobile
On Aug 2, 2012, at 4:46 PM, Saul Mora ***@***.*** wrote:
you mean, people will just use code without understanding how and why it works?
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/3241738
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Made this "Fix" but I'm concerned about enabling more problems down the line for people by automatically easing this one without them understanding.