1

Possible Duplicate:
Does NSFetchedResultsController Observe All Changes to Persistent Store?

I am getting this Error:

Serious application error.  Exception was caught during Core Data change processing.    
This is usually a bug within an observer of  
NSManagedObjectContextObjectsDidChangeNotification.    
CoreData could not fulfill a fault for [...]  with userInfo {
NSAffectedObjectsErrorKey =     (
    "<EntitySetsCards: 0x94664a0> (entity: EntitySetsCards; id: 0x27bb70 
[...] data: <fault>)"
);

This Error occurs, when i do changes in my EntitySetsCards.
I have a TableView where i populate it with NSFetchedResultsController.
I choose a row of tableView and my DetailView gets loaded.
In Detailview i am iterating through the rows of the tableview. On return to tableview i am doing changes in my entitys:
EntitySetsCards
EntitySetsCardsInbox

In both Entitys, i am updating a property. And here is the code, where the update happens:

- (IBAction) actionBtnBack:(id) sender {


//[self hideAllButtons];

//diese variable führt zu absturz daher hier mal nil setzen als test
detailCardsArray = nil;

NSError *error = nil;

 //archived hier updaten auf 1!
NSFetchRequest *fetchRequestARCHIV = [[[NSFetchRequest alloc] init] autorelease];
NSEntityDescription *entityARCHIV = [NSEntityDescription entityForName:@"EntitySetsCards" inManagedObjectContext:managedObjectContext];
[fetchRequestARCHIV setEntity:entityARCHIV];

NSFetchRequest *fetchRequestINBOX = [[[NSFetchRequest alloc] init] autorelease];
NSEntityDescription *entityINBOX = [NSEntityDescription entityForName:@"EntitySetsCardsInbox" inManagedObjectContext:managedObjectContext];
[fetchRequestINBOX setEntity:entityINBOX];


NSNumber *one = [[[NSNumber alloc] initWithInt:1] autorelease];


NSMutableSet* existingCards = [NSMutableSet set];
NSMutableArray *filteredArray3 = [[[NSMutableArray alloc] init] autorelease];

for (id object in collectionOfCardIds) {
    if (![existingCards containsObject:object]) {
        [existingCards addObject:object];
        [filteredArray3 addObject:object];
    }
}


for (int i=0; i <[filteredArray3 count]; i++) {

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"cardId == %@", [filteredArray3 objectAtIndex:i]];
    [fetchRequestARCHIV setPredicate:predicate];


    NSPredicate *predicateInb = [NSPredicate predicateWithFormat:@"cardId == %@", [filteredArray3 objectAtIndex:i]];
    [fetchRequestINBOX setPredicate:predicateInb];

    EntitySetsCards *entitySetsCards = [[managedObjectContext executeFetchRequest:fetchRequestARCHIV error:&error] objectAtIndex:0];
    EntitySetsCardsInbox *entitySetsCardsInbox = [[managedObjectContext executeFetchRequest:fetchRequestINBOX error:&error] objectAtIndex:0];



    entitySetsCards.archived = one;
    entitySetsCardsInbox.archived = one;


    [self.managedObjectContext save:&error];

    if (![managedObjectContext save:&error]) { 
        NSLog(@"Problem saving: %@", [error localizedDescription]); 
    }


[self dismissModalViewControllerAnimated:YES];
}
Community
  • 1
  • 1
brush51
  • 5,691
  • 6
  • 39
  • 73

0 Answers0