Bronze Challenge Chapter 27

I think this one was pretty easy:

  @IBAction func addButtonPressed(_ sender: UIButton) {
    guard let todo = itemTextField.text, todo != "" else {
      return
    }
    todoList.add(todo)
    itemTextField.text = ""
    tableView.reloadData()
  }

I came up with the same as you, but I also added an if statement to deal with not adding empty rows:

@IBAction func addButtonPressed(_ sender: UIButton) {
    guard let todo = itemTextField.text else {
        return
    }
    if todo != "" {
        todoList.add(todo)
        itemTextField.text = ""
        tableView.reloadData()
    }

It’s better to use the isEmpty() method in String than comparing to “”, it makes the code easier to read

Thanks a lot for such wonderful information and really appreciate it as it proved really helpful.