Подскажите, пожалуйста, почему может возникать ошибка, при удалении последней ячейки в секции. То есть если удалять сколько угодно - проблем нет, анимация работает, а если в секции осталась одна ячейка, то при удалении вылетает ошибка. Единственное, что помогает, это удаление вот этого:
if let indexPath = indexPath {
tableView.deleteRows(at: [indexPath], with: .fade)
}
Тогда ячейка удаляется, но без анимации, а после этого и исчезает сама секция, по релоадДата.
Подскажите, пожалуйста, как побороть это счастье?
вот так выглядит ошибка:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 1. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (2), 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).'