报错提示:
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), 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).’
我是在使用tabelView删除一行cell时 报这个错.
objectC
UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSMutableArray *tempModelAry = [NSMutableArray arrayWithArray:self.modelAry];
[tempModelAry removeObjectAtIndex:indexPath.row];
self.modelAry = tempModelAry.copy;
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}];
原因是 self.modelAry = tempModelAry.copy; 我在self.modelAry的set方法里写了 tabelView reload 的方法.
解决办法是 把self.modelAry 变成 _modelAry 就好了.