building lists

OS: 10.15.2

Xcode: 11.3 (11C29)


Lesson: Building Lists & Navigation

Section 6 - List & Detail


My code:

import SwiftUI


struct LandmarkList: View {

var body: some View {

NavigationView {

List(landmarkData) { landmark in

NavigationLink(destination: LandmarkDetail()){

LandmarkRow(landmark: landmark)

}

.navigationBarTitle(Text("Landmarks"))

}

}


struct LandmarkList_Previews: PreviewProvider {

static var previews: some View {

LandmarkList()

}

}

}

}


var body line returns error: 'Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type"

Next line - NavigationView { gives a yellow warning claiming the Result of 'NavigationView<Content>' initializer is unused


I think I have copied this perfectly from the lesson. Did the new XCode change something? If I've missed something please help me spot it - and if there is any additional explanation, I need to learn!

Thanks!!

Answered by rudedogg in 400121022

I think it's just your brackets.


You should have one more on the `var body` block, and one less on the `PreviewProvider` block.

Accepted Answer

I think it's just your brackets.


You should have one more on the `var body` block, and one less on the `PreviewProvider` block.

Brilliant. Good eye!!!

Many thanks.

No problem, happy to help!

building lists
 
 
Q