Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

MR_inContext: works on objects with temporary IDs #378

Closed
wants to merge 2 commits into from

2 participants

Neal Ehardt Saul Mora
Neal Ehardt

This is in response to Issue 312.

Saul Mora
Owner
Neal Ehardt

Done. I hope this is right... #379

Neal Ehardt NealEhardt closed this
Saul Mora
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
13 MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.m
View
@@ -222,6 +222,19 @@ + (BOOL) MR_truncateAll
- (id) MR_inContext:(NSManagedObjectContext *)otherContext
{
NSError *error = nil;
+
+ if (self.objectID.isTemporaryID)
+ {
+ BOOL success = [self.managedObjectContext obtainPermanentIDsForObjects:@[self] error:&error];
+ if (!success)
+ {
+ [MagicalRecord handleErrors:error];
+ return nil;
+ }
+ }
+
+ error = nil;
+
NSManagedObject *inContext = [otherContext existingObjectWithID:[self objectID] error:&error];
[MagicalRecord handleErrors:error];
Something went wrong with that request. Please try again.