Отображение пустой строки UITableView с использованием пустого двумерного массива строк в Swift 4 - PullRequest
1 голос
/ 09 апреля 2020

Я пытаюсь отобразить пустую строку в UITableView, используя пустой массив строк 2D, но продолжаю получать ошибку «Индекс вне диапазона» в строке «cell.textLabel? .Text». Может кто-нибудь, пожалуйста, помогите мне? Спасибо.

import UIKit

class TableViewController: UITableViewController {

    var titleDiplay = [[String]()]

    override func viewDidLoad() {
        super.viewDidLoad()
        print(titleDiplay)

    }

    // MARK: Table view data source

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        return titleDiplay.count
    }


    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)

        cell.textLabel?.text = titleDiplay[indexPath.section][indexPath.row]

        return cell
    }

}
...