Setting Up the UITableView

Your model class is now ready. Return to your controller in ViewController.swift. Add an instance of TodoList as a new property and change addButtonPressed(_:) to add items to todoList instead of printing them.

Listing 27.6  Adding the model class to the controller as a property (ViewController.swift)

class ViewController: UIViewController {

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

    let todoList = TodoList() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction ...

Get Swift Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.