我在嘗試從核心數據中刪除對象時出現錯誤「NSManagedObjectContext無法刪除其他上下文中的對象」。 我使用下面的代碼在負載之後的正常核心數據取出如何從核心數據和表視圖中刪除行
NSFetchedResultsController *controller = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:appDelegate.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
controller.delegate=self;
BOOL success = [controller performFetch:&error];
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSManagedObject *managedObject = [controller objectAtIndexPath:indexPath];
//(Alert view)
}
在警報視圖clickedButtonAtIndex功能,我試圖刪除從appDelegate.managedObjectContext該特定管理對象,而是一個錯誤「的的NSManagedObjectContext不能刪除在其他上下文對象」發生在線路
[appDelegate.managedObjectContext deleteObject:managedObject];
我試圖與其他管理對象的上下文,
NSManagedObjectContext *context= [controller managedObjectContext];
但得到相同的錯誤。 任何人都可以請告訴爲什麼會出現此錯誤,並從表視圖和核心數據中刪除特定行的解決方案?
?正如錯誤所述,您不能刪除其他上下文中的對象。 – duci9y