Bronze Challenge (simple way)


#1

import UIKit

class ViewController: UIViewController {

@IBOutlet var itemTextField: UITextField!
@IBOutlet var tableView: UITableView!

let todoList = TodoList()

override func viewDidLoad() {
    super.viewDidLoad()
    tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
    tableView.dataSource = todoList
}

@IBAction func addButtonPressed(sender: UIButton) {
    guard let text = itemTextField.text where text != "" else {
                           // "where text != "" ": is my add for the Bronze Challenge
        return
    }
    todoList.addItem(text)
    tableView.reloadData()
    itemTextField.text = ""                        // my add for the Bronze Challenge

}

}