Skip to content

Commit

Permalink
Allow assertion to pass if localObject is returned nil
Browse files Browse the repository at this point in the history
  • Loading branch information
blakewatters committed Feb 7, 2013
1 parent e7352f7 commit a19f1a5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Code/Network/RKResponseMapperOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,11 @@ - (RKMappingResult *)performMappingWithObject:(id)sourceObject error:(NSError **
if (objectID) {
if ([objectID isTemporaryID]) RKLogWarning(@"Performing object mapping to temporary target objectID. Results may not be accessible without obtaining a permanent object ID.");
NSManagedObject *localObject = [self.managedObjectContext existingObjectWithID:objectID error:&blockError];
NSAssert([localObject.managedObjectContext isEqual:self.managedObjectContext], @"Serious Core Data error: requested existing object with ID %@ in context %@, instead got an object reference in context %@. This may indicate that the objectID for your target managed object was obtained using `obtainPermanentIDsForObjects:error:` in the wrong context.", objectID, self.managedObjectContext, [localObject managedObjectContext]);
NSAssert(localObject == nil || [localObject.managedObjectContext isEqual:self.managedObjectContext], @"Serious Core Data error: requested existing object with ID %@ in context %@, instead got an object reference in context %@. This may indicate that the objectID for your target managed object was obtained using `obtainPermanentIDsForObjects:error:` in the wrong context.", objectID, self.managedObjectContext, [localObject managedObjectContext]);
if (! localObject) {
RKLogWarning(@"Failed to retrieve existing object with ID: %@", objectID);
RKLogCoreDataError(blockError);
return;
}
self.mapperOperation.targetObject = localObject;
} else {
Expand Down

0 comments on commit a19f1a5

Please sign in to comment.