这一段会crash,当数据很快被插入的时候
// WEAKSELF
// [self exChangeMessageDataSourceQueue:^{
// NSMutableArray *messages = [NSMutableArray arrayWithArray:weakSelf.messages];
// [messages addObject:addedMessage];
//
// [weakSelf exMainQueue:^{
// weakSelf.messages = messages;
//
// NSMutableArray *indexPaths = [NSMutableArray arrayWithCapacity:1];
// [indexPaths addObject:[NSIndexPath indexPathForRow:weakSelf.messages.count - 1 inSection:0]];
// [weakSelf.messageTableView beginUpdates];
// [weakSelf.messageTableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
// [weakSelf.messageTableView endUpdates];
//
// [weakSelf scrollToBottomAnimated:YES];
// }];
// }];
XHMessageTableViewController.m
[weakSelf.messageTableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
更换成 [weakSelf.messageTableView reloadData]
+1,遇到了相同的问题,害惨我了。。他这个插入消息的方法写的有很大问题。滥用GCD啊! 千万不要用他的addMessage方法,自己写一个: 要在主线程执行
XHMessage *xhMessage = [self getXHMessageByMsg:message];
[self.messages addObject:xhMessage];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.messages.count -1 inSection:0];
[self.messageTableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[self scrollToBottomAnimated:YES];
@bitnpc
I am also facing same issue .
Please help me
how to add own method to add method
