I have following View and I need to pass item
content to another View (DetailsEvent.swift), I am using NavigationLink
. (I'm using Xcode 11 GM)
struct Events: View {
@ObservedObject var networkManager = NetworkManager()
var body: some View {
NavigationView{
List(self.networkManager.eventos.events){ item in
NavigationLink(destination: DetailsEvent(item: item)) {
VStack(alignment: .leading) {
HStack {
Image(systemName: "calendar")
.foregroundColor(.gray)
Text(item.start_date)
.font(.subheadline)
.foregroundColor(.gray)
}
Text(item.title)
.font(.headline)
}
}
}
.navigationBarTitle("Events")
}
}
But it gives me the following error:
Argument passed to call that takes no arguments
Without passing any variable: NavigationLink (destination: DetailsEvent ()
everything works fine.
DetailsEvent.swift
struct DetailsEvent: View {
var body: some View {
Text("here details content")
}
}
Your struct has no property called item. You need something like this:
struct DetailsEvent: View {
let item: Event
var body: some View {
Text("here details about \(item.title)")
}
}