- (void)registerCellCallBack:(id<CellCallBack>)callBack {
int i = 0;
for(; i < _dataSource.count; ++i) {
id<CellCallBack> oldCallBack = _dataSource[i];
if([callBack key] <= [oldCallBack key]) {
break;
}
}
if(i < _dataSource.count) {
[_dataSource insertObject:callBack atIndex:i];
} else {
[_dataSource addObject:callBack];
}
[self.table beginUpdates];
[self.table insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
[self.table endUpdates]; //--crashed here called "NSInternalInconsistencyException(SIGABRT)"
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _dataSource.count;
}
甚至在iOS9是很好的代碼,在iOS10墜毀,但是當我調試我的代碼不會出現。當我打電話[的tableView insertRowsAtIndexPaths:withRowAnimation:],墜毀在iOS10
崩潰信息:
無效更新:在更新後的數 包含在現有部分中的行的部分0的行數無效(7) 必須等於的數包含在 更新(0)之前的那一行中包含的行,加上或減去從該部分插入或刪除 的行數(插入1個,刪除0),加上或減去移入或移出該部分的行的編號 (0移入,0移出)。
只是刪除更新開始和結束的更新。而已。 –