I am trying to display an empty row in the UITableView by using an empty 2D string array but keep on getting the “Index out of range” error on the "cell.textLabel?.text" line. Can someone please help me? Thank you.
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
}
}