Displaying Dynamic Data

It is fine to see previews that display hardcoded strings, but eventually TahDoodle should display user-generated tasks – and not just one task, but a whole list of them. You need to define a type to model a task and a place to store a collection of them.

Define a Task type in a new Swift file called Task.swift.

Example 28.7. Defining Task (Task.swift)
import Foundation

struct Task {

    let title: String

}

Your Task type is very bare-bones right now, but it will grow over time as the needs of your program evolve.

Next, define a type in a new file named TaskStore.swift that will hold and manage a collection of tasks. Your code will emit an error, which you will fix in a subsequent step.

Example 28.8. Defining TaskStore ...

Get Swift Programming: The Big Nerd Ranch Guide, 3rd Edition 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.