Recently, when dealing with bugly problems, we always see that the reply list has broken down, but we can’t start because there are no specific details
We only know the failure of the conversationlistviewcontroller class. The problem is this and only this information, so we can only start with tableview
#17009 NSInternalInconsistencyException
UITableView (<UITableView: 0x10e1ad400; frame = (0 88; 414 327); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x280df53e0>; layer = <CALayer: 0x2807a1040>; contentOffset: {0, 156.33333333333334}; contentSize: {414, 394}; adjustedContentInset: {0, 0, 0, 0}>) failed to obtain a cell from its dataSource (<CustomChatUIViewController: 0x10e1b0000>)
YuLin + 10902176
Searching online for half a day, uitableview common crashes mainly include the following categories:
The uitableview is not refreshed synchronously after the datasource is updated
UITableView dataSource is not set
Invalid update
failed to obtain a cell from its dataSource
Finally, it is found that in order to avoid array out of bounds, this judgment is added and nil is returned, which will result in failed to obtain a cell from its datasource
if (_conversationList.count<=indexPath.row) {
return nil;
}
//After modification
if (_conversationList.count<=indexPath.row) {//datasource is not synchronized, there will be an out-of-bounds problem, return nil, have failed to obtain a cell from its dataSource problem
static NSString *ident = @"tempcell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ident];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ident];
}
cell.hidden = YES;
return cell;
}
// look at the effect of the later version. The crashing rate of conversationlistviewcontroller is reduced. That’s the problem