So I'm updating a tableview by inserting/deleting/reloading rows as needed, but, as I'm not 100% confident that the tableview will always update correctly, is there any way to fail safely from a bad batch of updates?
Right now, I have this:
// Try to animate the updates. If something goes wrong, just reloadData.
@try {
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:deleteArray withRowAnimation:UITableViewRowAnimationMiddle];
[tableView reloadRowsAtIndexPaths:reloadArray withRowAnimation:UITableViewRowAnimationNone];
[tableView insertRowsAtIndexPaths:insertArray withRowAnimation:UITableViewRowAnimationMiddle];
[tableView endUpdates];
}
@catch (NSException * e) {
if([[e name] isEqualToString:NSInternalInconsistencyException]){
[tableView reloadData];
NSLog(@"animation failed, just reloading data");
}
else {
@throw e;
}
}
However, once it hits that exception, reloadData seems to not work. Is there any other way to basically reset the UITableView into a working state?