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
}