Cell.textlabel.text problem

Hi, I’m trying to set my cell.textLabel.text = “No items added Yet” if the the todoItems array is nil. For some reason I just can’t figure it out. When the array is nil, the else block of code doesn’t execute.

var todoItems: Results<Item>?

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "TodoItemCell", for: indexPath)
    if let item = todoItems?[indexPath.row] {
        cell.textLabel?.text = item.title
        cell.accessoryType = item.done == true ? .checkmark : .none
    } else {
        cell.textLabel?.text = "No Items Added Yet"
    return cell

what is your code in your viewDidLoad?

I have no code in viewDidLoad

thats the problem. your todoItems is nil being it was not populated in the viewDidLoad, try going through the match app again and you will see that the array of cards in populated at the ViewDidLoad