"попытка удалить строку ..." сбой, но я не сознательно удаляю ни одну строку - PullRequest
1 голос
/ 11 июля 2019

Итак, я получаю это:

2019-07-10 13:33:49.054504-0700 akin[60767:2710637] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 2 from section 0 which only contains 1 rows before the update'

Когда я ищу в своем проекте deleteRows, ничего не появляется.

Вот трассировка стека: enter image description here

Вот мой код для трассировки стека

@objc func handlePillTap(sender: UITapGestureRecognizer) {
    let oldContext = movingPillRight.isActive ? "romance" : "social"
    let sideTouched: Side = sender.location(in: movingPill).x > movingPill.frame.width / 2 ? .right : .left
    updateModelContext(with: sideTouched)
    styleView(importance: questionCellDelegate?.importance())
    movePill(sideTouched)
    let newContext = movingPillRight.isActive ? "romance" : "social"
    if oldContext != newContext {
        pillDelegate?.changeContext(Context(rawValue: newContext)!)
    }
    guard let delegate = questionCellDelegate else {return}
    updateViewOfCell(from: delegate.question,
                         currentContext: currentQuestionContext,
                     delegate: pillDelegate as? UIViewController)
}
func changeContext(_ context: Context) {
    currentQuestionContext = context
    topBar.context = currentQuestionContext
    responseTV.safelyReload(
    questionsWrapper.question.responses.indexPaths, with: .fade )
}
func safelyReload(_ rows: [IndexPath], with animation: RowAnimation) {
    DispatchQueue.main.async {
        self.reloadRows(at: rows, with: animation)
    }
}

Понятия не имею, почему я получаю эту ошибку.

1 Ответ

1 голос
/ 11 июля 2019

Количество строк, которое я возвращал в numberOfRows, не равно количеству переданных в indexPaths для reloadRows(at:

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...