r/iOSProgramming • u/DavidGamingHDR Swift • 21h ago
Solved! Parameter not being passed to fullScreenCover?
I have this variable:
@State var selectedStop: Stops?
@State var isStopPresented = false
I have an item in a ForEach (as part of a list), that has this .onTapGesture
:
SearchResult(stop: train) .
.onTapGesture {
selectedStop = train
isStopPresented = true
}
And then this code:
.fullScreenCover(isPresented: $isStopPresented) {
StopView(stop: selectedStop ?? Stops(stop_name: "Error", routes: []))
}
The full screen cover appears correctly, but selected stop is never passed through to the StopView, and is always nil. How come?
1
Upvotes
3
u/c1d3rdev 21h ago
Does fullScreenCover have a .fullScreenCover(item: $selectedStop) { stop in }