When I delete the last row from a tableview with:
tableView.deleteRows(at: [indexPath], with: .middle)
and change my table's data source to an another array:
if orders.isEmpty {
return ABCDArray.count
} else {
return orders.count
}
It gives me this error:
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 (20) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
How can I solve that? What is the problem with changing data source?