0

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

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 ответ 1

0

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

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.