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
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COCould you add the code that create the objects and the crash? what is your context architecture (parent-child, merge, detached)? were the related objects on the main context deleted?
      singulars
    2. COPlease give a little more detail about how your code works. Specifically: (a) you have more than one managed object context-- are they related by a parent/child relationship? (b) When you save "again", how *exactly* are you doing this? Post relevant code.
      singulars
    3. CO@DanShelly I definitely would add the code that created the crash but it is sprinkled throughout the app - Numerous objects are crashing all over the place, in different view controllers and different methods! I will add the code the created the main objects - it is code that imports facebook friends on a background thread - creating a Person object for each facebook friend that is imported. It also creates other related objects - but the objects that it does NOT create are the ones that I am concerned about, when trying to access them causes this error.
      singulars
 

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