Incorrect argument label

Hi there,

I am just starting to get into Swift. I have been following Apple's own SwiftUI Tutorials (linked here), but I got stuck at "Section 6 - Set Up Navigation Between List and Detail". In step 6, when I try to "wrap the returned row in a NavigationLink", Xcode tells me:

"Incorrect argument label in call (have '🏷️ ', expected ':destination:')"

"Type '() -> LandmarkDetail' cannot conform to 'StringProtocol'; only struct/enum/class types can conform to protocols"

"Type '() -> LandmarkRow' cannot conform to 'View'; only struct/enum/class types can conform to protocols"

My code is as follows:

import SwiftUI

struct LandmarkList: View {

    var body: some View {

        NavigationView {

            List(landmarks) { landmark in

                NavigationLink {

                    LandmarkDetail()

                } label: {

                    LandmarkRow(landmark: landmark)

                }

            }

            .navigationTitle("Landmarks")

        }

    }

}



struct LandmarkList_Previews: PreviewProvider {

    static var previews: some View {

        LandmarkList()

    }

}

/*Stuck at Section 6

Set Up Navigation Between List and Detail

*/

May I ask why that happens? In fact I have tried copying the exact code from the Apple's page but it is giving me the same errors. I'm running Xcode V12.0.1 on Catalina. Thank you in advance for any help, and please excuse my ignorance.

I tested in Xcode 13.2 and it works.

Problem is that syntax in Xcode 12 was different.

With Xcode 12, you should write:

struct LandmarkList: View {
    var body: some View {
        NavigationView {
            List(landmarks) { landmark in
                NavigationLink(destination: LandmarkDetail(landmark: landmark)) {
                    LandmarkRow(landmark: landmark)
                }
            }
            .navigationTitle("Landmarks")
        }
    }
}
Incorrect argument label
 
 
Q