Accepting User Input

It is time to let the user manage their own list of tasks, rather than only looking at yours. To do this, you will make your view hierarchy even deeper by fleshing out the ContentView to contain a TaskListView, as well as a place to enter text and a submit button.

You are going to reinstall the ContentView as the root view created by the TahDoodleApp. Start in ContentView.swift by giving the ContentView a store that it will, in turn, pass along to its TaskListView. Make sure to update the preview provider to give it your sample data.

Example 28.16. Giving the ContentView a store (ContentView.swift)
import SwiftUI

struct ContentView: View {
    
    let taskStore: TaskStore

    var body: some View {
        Text("Hello, world!")
            .padding()
        

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.