UITableView internal inconsistency

Viewed 1262

im updating a tableview cell on some condition in the following way:

tableView.moveRow(at: indexPath, to: IndexPath(row: 0, section: 1))

im getting crashes on the firebase crashlytics as below:

UITableView internal inconsistency: encountered out of bounds global row index while preparing batch updates (oldRow=1, oldGlobalRowCount=1)

if anyone has an idea what the case could be, thanks

1 Answers

Your table view datasource seems like not updating before it attempts to redraw. Try placing your code between beginUpdated and endUpdates

tableView.beginUpdates()
tableView.moveRow(at: indexPath, to: IndexPath(row: 0, section: 1))
tableView.endUpdates()
Related