April 2020
Beginner
316 pages
8h 20m
English
Let's start by heading on over to our ContentView.swift. Now, remember, that's ContentView.swift in our My Favourite Recipes Watch Extension group (not our parent app). Make the following highlighted changes:
struct ContentView: View { var recipes = [RecipeModel]() var body: some View { VStack { Text("Recipes") .font(.headline) List(recipes, id: \.id) { recipe in Text("\(recipe.name)") } } } }
Here, we've started by creating a variable for our recipes. This is an array of RecipeModel() from our parent class.
Next, into the body of our struct, we've added some familiar controls: VStack, which wraps around Text(), and a List() view.
Much like our app, the List() view iterates around our array of recipes and ...
Read now
Unlock full access