April 2020
Beginner
316 pages
8h 20m
English
Back before the days of SwiftUI, to achieve multiple screens, we would need to add additional HostingController to our storyboard. But with SwiftUI, we can eliminate this by having just one default HostingController, which acts as a harness or entry point for our watchOS app.
To create a new screen, we'll first need to create a new file. Highlight the My Favourite Recipes Watch Extension group and create a new Swift UI View file and call it IngredientsView.swift.
Once created, add the highlighted code as follows:
var ingredients = [String]()var recipeName = "" var body: some View { VStack { Text(recipeName) .font(.headline) List(ingredients, id: \.self) { ingredient in Text(ingredient) } }}
There's nothing too ...
Read now
Unlock full access