Skip to content

Commit

Permalink
MR_inContext: works on objects with temporary IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
NealEhardt authored and tonyarnold committed Aug 20, 2013
1 parent 15cdd95 commit ffe8372
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -226,6 +226,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];

Expand Down

0 comments on commit ffe8372

Please sign in to comment.