我的tableview datasoure来自一个数组,它从托管对象上下文的executeFetchRequest方法中获取数据。在commitEditingStyle委托,我得到这个错误:删除表格视图单元格,但“行数无效”显示
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1),
委托:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.managedOjbectContext deleteObject:[self.myEvents objectAtIndex:indexPath.row]];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView reloadData];
}
}
它工作。谢谢。 – 2013-02-22 12:26:15