- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSManagedObjectContext *context = [self managedObjectContext];
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSLog(@"%@",context);
// Delete object from database
[context deleteObject:[self.devices objectAtIndex:indexPath.row]];
NSLog(@"%@",context);
NSError *error = nil;
if (![context save:&error]) {enter code here
NSLog(@"Can't Delete! %@ %@", error, [error localizedDescription]);
return;
}
// Remove device from table view
[self.devices removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
ошибка является NSManagedObjectContext не может удалять объекты в других контекстахNSManagedObjectContext не может удалять объекты в других контекстах
Возможный дубликат [NSManagedObjectContext не может удалять объекты в других контекстах] (http://stackoverflow.com/questions/5863724/an-nsmanagedobjectcontext -cannot-delete-objects-in-other-contexts) – Jeff