2
0

Fix usage of dubious objectID in global context.

This commit is contained in:
Maarten Billemont
2017-04-29 23:52:57 -04:00
parent 6d9be3fdfe
commit 834e94ebd5
10 changed files with 58 additions and 58 deletions

View File

@@ -34,6 +34,23 @@
@end
@implementation NSManagedObject(MP)
- (NSManagedObjectID *)permanentObjectID {
NSManagedObjectID *objectID = self.objectID;
if ([objectID isTemporaryID]) {
NSError *error = nil;
if (![self.managedObjectContext obtainPermanentIDsForObjects:@[ self ] error:&error])
MPError( error, @"Failed to obtain permanent object ID." );
objectID = self.objectID;
}
return objectID.isTemporaryID? nil: objectID;
}
@end
@implementation MPSiteQuestionEntity(MP)
- (NSString *)resolveQuestionAnswerUsingKey:(MPKey *)key {