Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 1. The number of rows contained in an existing section after the update (22) must be equal to the number of rows contained in that section before the update (22), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
由于未捕获异常“NSInternalInconsistencyException”而终止应用程序,
原因:“无效更新:section 1中的行数不正确。更新后现有段中包含的行数(22)必须等于该行中包含的更新前的行数 (22),加或减该部分插入或删除的行数(0插入,1删除)和加或减,移入或移出该部分的行数(0移入,0移出)。
解决方案:因为数据是从coredata取出的,删除单元格因该先将数据从coredata删除。
if (editingStyle == UITableViewCellEditingStyleDelete) {
if (indexPath.row < [self.cloudFileArray count]) {
[tableView beginUpdates];
id object = [self.cloudFileFetchController objectAtIndexPath:indexPath];
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
NSManagedObjectContext *ctx = [appDelegate.localManager managedObjectContext];
[ctx deleteObject:object];
[tableView reloadData];
[tableView endUpdates];
}
}
网友评论