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

@@ -80,7 +80,7 @@
- (void)setSite:(MPSiteEntity *)site {
_siteOID = [site objectID];
_siteOID = site.permanentObjectID;
_multiple = [site.questions count] > 0;
[self.tableView reloadData];
[self updateAnimated:NO];
@@ -301,8 +301,8 @@
- (void)setQuestion:(MPSiteQuestionEntity *)question forSite:(MPSiteEntity *)site inVC:(MPAnswersViewController *)answersVC {
_siteOID = site.objectID;
_questionOID = question.objectID;
_siteOID = site.permanentObjectID;
_questionOID = question.permanentObjectID;
_answersVC = answersVC;
[self updateAnswerForQuestion:question ofSite:site];
@@ -333,14 +333,7 @@
question.keyword = keyword;
if ([context saveToStore]) {
// if ([question.objectID isTemporaryID]) {
// NSError *error = nil;
// [context obtainPermanentIDsForObjects:@[ question ] error:&error];
// if (error)
// MPError( error, @"Failed to obtain permanent object ID: %@" );
// }
_questionOID = question.objectID;
_questionOID = question.permanentObjectID;
[self updateAnswerForQuestion:question ofSite:site];
if (didAddQuestionObject)

View File

@@ -171,7 +171,7 @@
- (void)setSite:(MPSiteEntity *)site animated:(BOOL)animated {
_siteOID = [site objectID];
_siteOID = site.permanentObjectID;
[self updateAnimated:animated];
}

View File

@@ -381,7 +381,7 @@ referenceSizeForFooterInSection:(NSInteger)section {
MPAvatarCell *userAvatar = [self selectedAvatar];
userAvatar.spinnerActive = YES;
if (!isNew && mainUser && [MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
MPUserEntity *user = [MPUserEntity existingObjectWithID:mainUser.objectID inContext:context];
MPUserEntity *user = [MPUserEntity existingObjectWithID:mainUser.permanentObjectID inContext:context];
BOOL signedIn = [[MPiOSAppDelegate get] signInAsUser:user saveInContext:context usingMasterPassword:nil];
PearlMainQueue( ^{
@@ -424,10 +424,10 @@ referenceSizeForFooterInSection:(NSInteger)section {
BOOL isNew = NO;
MPUserEntity *user = [self userForAvatar:avatarCell inContext:mainContext isNew:&isNew];
NSManagedObjectID *userID = user.objectID;
if (isNew || !user)
return;
NSManagedObjectID *userID = user.permanentObjectID;
[PearlSheet showSheetWithTitle:user.name
viewStyle:UIActionSheetStyleBlackTranslucent
initSheet:nil tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
@@ -737,7 +737,7 @@ referenceSizeForFooterInSection:(NSInteger)section {
NSMutableArray *userIDs = [NSMutableArray arrayWithCapacity:[users count]];
for (MPUserEntity *user in users)
[userIDs addObject:user.objectID];
[userIDs addObject:user.permanentObjectID];
self.userIDs = userIDs;
}])
self.userIDs = nil;
@@ -765,7 +765,7 @@ referenceSizeForFooterInSection:(NSInteger)section {
NSManagedObjectID *selectUserID = [MPiOSAppDelegate get].activeUserOID;
if (!selectUserID)
selectUserID = [self selectedUserInContext:[MPiOSAppDelegate managedObjectContextForMainThreadIfReady]
isNew:&isNew].objectID;
isNew:&isNew].permanentObjectID;
[self.avatarCollectionView reloadData];
NSUInteger selectedAvatarItem = isNew? [_userIDs count]: selectUserID? [_userIDs indexOfObject:selectUserID]: NSNotFound;