My NavigationLink does not appear to be working as advertised, in that it is not accepting arguments to display text or a view. My code is as follows:
struct MainContentView: View {
var body: some View {
// MARK: PROPERTIES
let mainData: [MainData] =
Bundle.main.decode("mainData.json")
// MARK: BODY
NavigationView {
List {
Image("hsSampleBack")
.resizable()
.scaledToFill()
.frame(height: 300)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
ForEach(mainData) { mainDataPoint in
NavigationLink(destination: Selection() {
Text("Text Here")
})
}//:LOOP
} //: LIST
.navigationBarTitle("Data Points", displayMode: .large)
} //: NAVIGATION
}
}
I am getting the following 2 error messages over my NavigationLink line:
Argument passed to call that takes no arguments
Missing argument for parameter #1 in call
If these seems contradictory to you, join the club. On the one hand it claims that no arguments are permitted, and then it's flagging a missing argument. It seems to want to call for a "Label" Text argument, which would be fine, except that I ultimately want to pass a View, which I have done successfully elsewhere.
Any thoughts on this?
Here is corrected syntax
ForEach(mainData) { mainDataPoint in
NavigationLink(destination: Selection()) {
Text("Text Here")
}
}//:LOOP