可能重复:
Does NSFetchedResultsController Observe All Changes to Persistent Store?
我收到此错误:
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>)"
);
当我在我的EntitySetsCards中进行更改时会发生此错误。
我有一个TableView,我用NSFetchedResultsController填充它
我选择了一行tableView,我的DetailView被加载了
在Detailview中,我正在迭代tableview的行。在返回tableview时,我正在对我的实体进行更改:
的 EntitySetsCards
EntitySetsCardsInbox
在两个实体中,我正在更新一个属性。 以下是更新发生的代码:
- (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];
}