Silver Challenge (simple way) - Chapter 27


#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")
    /*  my modification for the Silver Challenge: I have then added a "Table View Cell" in the storyboard and inside the Attributes inspector I set the Identifier to Cell. */
    tableView.dataSource = todoList
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

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

}


Silver Challenge help needed