Post

Replies

Boosts

Views

Activity

How to perform extract subview operation?
Hi everyone, I want to perform the tutorial from video WWDC19 - 204. Here is an example of building the "Rooms" application. At 11 minutes, the author of the video, Jacob Xiao, shows how he performs the extract subview operation. But when I try to repeat this operation an error occurs - Cannot find 'room' in scope. My code and code of Jacob Xiao are the same. import SwiftUI struct ContentView: View {     var rooms: [Room] = []         var body: some View {         NavigationView {                         List(rooms) { room in                 ExtractedView()             }                       .navigationBarTitle(Text("Rooms"))         }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView(rooms: testData)     } } struct ExtractedView: View {     var body: some View {         NavigationLink(             destination: Text(room.name)) { // Cannot find 'room' in scope             Image(room.thumbnailName)                 .cornerRadius(8)             VStack(alignment: .leading) {                 Text(room.name)                 Text("\(room.capacity) people")                     .font(.subheadline)                     .foregroundColor(.secondary)             }         }     } } I think the reason is that SwiftUI on my computer is a newer version, so some of the previous functions may not work. Could you tell me how to perform this subview extract operation today?
2
0
3.4k
Aug ’21
How to Choose the WatchLandmarks target in SwiftUI Tutorial?
Hi everyone, I am studying SwiftUI on the Apple tutorial - https://developer.apple.com/tutorials/swiftui/creating-a-macos-app. In the Creating a MacOS App chapter in section 3 Update a Row View, there is a following instruction: Step 6 Choose the WatchLandmarks target to see a watchOS preview of the list. How to do this? It should be easy and simple, but somehow I haven't found it.
1
0
642
Apr ’21