Ошибка при удалении элемента из таблицы в Swift

Я пытаюсь реализовать функцию удаления в моем приложении, позволяющую пользователям удалять информацию, хранящуюся в основных данных и представленную в виде таблицы.

вот мой код:

 func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    if (editingStyle == .Delete){


    tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic) //error on this line

        }
}

ошибка заключается в следующем:

Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-3318.16.14/UITableView.m:1582
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 (6) must be equal to the number of rows contained in that section before the update (6), 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).'


Что я делаю неправильно? Как я могу исправить эту ошибку?

Ответы на вопрос(1)

Ваш ответ на вопрос