Реализация удаления строки в tableView, редактирование в 3 секции не включается

введите сюда описание изображения

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    switch indexPath.section {
    case 0:
        guard let cell = tableView.dequeueReusableCell(withIdentifier: "BossCell", for: indexPath) as? BossCell else {
            fatalError("Cannot dequeue: \(self)")
        }
        cell.person = workers.boss[indexPath.row]
        return cell

    case 1:
        guard let cell = tableView.dequeueReusableCell(withIdentifier: "StaffCell", for: indexPath) as? StaffCell else {
            fatalError("Cannot dequeue: \(self)")
        }
        cell.person = workers.staff[indexPath.row]
        return cell

    case 2:
        guard let cell = tableView.dequeueReusableCell(withIdentifier: "AccountantCell", for: indexPath) as? AccountantCell else {
            fatalError("Cannot dequeue: \(self)")
        }
        cell.person = workers.accountant[indexPath.row]
    default:
        return UITableViewCell()
    }

    return UITableViewCell()
}

override func setEditing(_ editing: Bool, animated: Bool) {
    super.setEditing(editing, animated: animated)
    tableView.setEditing(editing, animated: animated)
}

func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { return true }

func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
    return .delete
}


func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        storageManager.deleteObject(from: indexPath)
        tableView.reloadData()
    }
}

Ответы (1 шт):

Автор решения: Oleg Soloviev

В case 2 забыли return cell. Попробуйте добавить.

→ Ссылка