I am facing a crash issue while inserting a row to tableview.This happens when pagination reload(Very Fast scrolling of tableview) table view and inserting row for ads happens almost similar time.
Ad inserting method
[self.news insertObject:adStory atIndex:index];
NSArray *paths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:index inSection:0]];
[[self tableView] beginUpdates];
[[self tableView] insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade];
[[self tableView] endUpdates];
OperationDidfinish
[_tableView relaoddata];
Crash Logs
*** 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 (45) must be equal to the number of rows contained in that section before the update (43), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
*** First throw call stack:
(0 CoreFoundation 0x000000010e8ebb0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010e357141 objc_exception_throw + 48
2 CoreFoundation 0x000000010e8efcf2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00000001088413b6 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x000000010c8d78e8 -[UITableView _endCellAnimationsWithContext:] + 16362
5 UIKit 0x000000010c8ee9cc -[UITableView _updateRowsAtIndexPaths:updateAction:withRowAnimation:] + 329
relaoddata? Basically do not callinsertRows.../deleteRows...andreloadDatasimultaneously.insertRows...does update the UI. AndbeginUpdates / endUpdateshas no effect when performing a singleinsert/delete/moveoperation. - vadian