April 2020
Beginner
316 pages
8h 20m
English
PreviewProvider is brand new to Xcode 11 and specifically new to SwiftUI. By creating a struct that conforms to the PreviewProvider protocol (which sits within your SwiftUI class; for example, ContentView.swift), along with a couple of lines of code, Xcode will automatically generate a preview of your SwiftUI View.
As we've seen so far, using the Automatic Preview window is a real treat, but there are a couple of scenarios that we need to be aware of.
So, let's start by stripping back our project a little. While removing the hardcoded values, make the following changes to the struct:
struct ContentView: View { var recipeNames = [String]() var body: some View { VStack { List(recipeNames, id: \.self) { name ...Read now
Unlock full access