April 2020
Beginner
316 pages
8h 20m
English
Now, let's compare how we'd do the exact same thing in SwiftUI:
struct SwiftUIView: View { let mockData = ["Recipe 1", "Recipe 2", "Recipe 3"] var body: some View { List(mockData, id: \.self) { recipe in Text(recipe) } } }
That's it, really – excluding the mockData variable, we have a total of three lines of code to do the work of everything we covered previously – amazing.
Let's dig a little deeper and have a look at some other comparisons. Remember how, in Chapter 6, Working with Navigation in SwiftUI, we looked at how to push to another SwiftUI view by wrapping a simple NavigationLink around our List View's iteration?
var body: some View { List(mockData, id: \.self) { recipe in NavigationLink(destination: ...Read now
Unlock full access