Adding multiple screens

With SwiftUI, this is one of the easiest things to implement in watchOS, especially compared to the original way of doing it.

Previously, you would set up a custom segue in your storyboard, then implement a delegate method to detect a tap on a row, and then wrap up the data you wanted to pass over into a dictionary, followed by unwrapping at the other end. It's nothing too difficultjust tedious.

Now, with SwiftUI, we can fix this with one simple little wrapper that you've already seen before. Take a look, and make the following highlighted changes in your ContentView() struct:

VStack {    Text("Recipes")        .font(.headline)    List(recipes, id: \.id) { recipe in    NavigationLink(destination: IngredientsView(ingredients: recipe.ingredients, ...

Get Learn SwiftUI 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.