Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Core Data could not fulfill a fault" for objects that were created in the appDelegate managedObjectContext on the main thread
    text
    copied!<p>I mistakenly created a group of objects on a background thread, which created a new managedObjectContext in which the objects were saved.</p> <p>This resulted in numerous "Core Data could not fulfill a fault" crashes in my live app. Please note - I am not trying to delete these objects - it is a problem with the way they were created, when I try to save them again afterwards in the app delegate (main) context on the main thread.</p> <p>The thing that is confusing is that I am seeing this error for other objects, objects of a different type. They can be related to the objects created in the background thread, though they themselves were not created in the in the background thread.</p> <p>I am confused as to how this could have happened. How could I get the "Core Data could not fulfill a fault" error for an object not created in the background thread, but the app delegate (main) context?</p> <p>And is there any way at all to go back and fix this mistake in the live apps of my users?</p> <p>Let me reference my other question, through which I discovered this error: <a href="https://stackoverflow.com/questions/19994482/core-data-could-not-fulfill-a-fault-for-objects-that-were-not-deleted">"Core Data could not fulfill a fault" for objects that were not deleted</a></p> <p>I wrote up a new question because I feel that it is a different issue - though most definitely related. </p> <p>Here is the code that created the objects in the background thread:</p> <pre><code>- (void)friendPickerViewControllerDidChooseFriends:(NSArray *)friends { __ENTERING_METHOD__ if (friends.count &gt; 0) { [[FacebookHelper sharedManager] friendPickerController].navigationController.navigationBar.userInteractionEnabled = NO; [self startProgressIndicator]; [self performSelectorInBackground:@selector(importFriends:) withObject:friends]; } else { [self dismissModalImportViewControllerAnimated];//releases picker delegates, etc } } #pragma mark - #pragma mark Import Friend - (void)importFriends:(NSArray*)friends { __ENTERING_METHOD__ for (NSDictionary&lt;FBGraphUser&gt; *friend in friends) { [self importFriend:friend withCompletion:^(void){ CGFloat friendNumber = [friends indexOfObject:friend]+1; CGFloat friendCount = friends.count; self.importProgress = friendNumber/friendCount; }]; } } - (void)importFriend:(NSDictionary&lt;FBGraphUser&gt;*)friend withCompletion:( void (^) (void) )completionBlock { __ENTERING_METHOD__ Person *myNewPerson = [GetObjectArrayHelper createNewPersonMocSaveNew:YES]; myNewPerson.facebookID = friend.id; myNewPerson.facebookName = friend.name; NSString *nameFirst = [friend.first_name stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *nameLast = [friend.last_name stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *imageID = friend.id; UIImage *pickedImage = nil; if(imageID){ pickedImage = [FacebookHelper imageForObject:imageID]; } DLog(@"pickedImage:%@",pickedImage); if(pickedImage){ [self setImagesForFacebookImage:pickedImage forPerson:myNewPerson]; } //we should ALWAYS have a name [Helper changePerson:myNewPerson firstName:nameFirst lastName:nameLast]; if(completionBlock) { completionBlock(); } } - (void)finishedImporting { __ENTERING_METHOD__ [SVProgressHUD showSuccessWithStatus:[self completeString]]; [self performSelector:@selector(dismissModalImportViewControllerAnimated) withObject:nil afterDelay:SV_PROGRESS_HUD_SUCCESS_DELAY]; } - (void)dismissModalImportViewControllerAnimated { __ENTERING_METHOD__ [Helper mocSave];//THIS SAVES IN THE APP DELEGATE MANAGED OBJECT CONTEXT - [SVProgressHUD dismiss]; [self dismissViewControllerAnimated:YES completion:^(void){ [[FacebookHelper sharedManager] friendPickerController].delegate = nil; [[FacebookHelper sharedManager] friendPickerController].navigationController.navigationBar.userInteractionEnabled = YES; }]; } </code></pre> <p>Please note that the objects that I am concerned about are not any of the objects created here (or in methods called here), but objects that later become associated with these objects.</p> <p>Why are THEY "Core Data could not fulfill a fault" crash? (I understand why any object created here or in a method called here would get it).</p> <p>Also - once I figure out why this mess happened (and fix the code that caused it) I need to fix the rogue objects in my users' live apps. I could really use some advise on that as well!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload