I have a NavigationView that displays a List of NavigationLinks e.g.:
NavigationView{
List {
ForEach (timers) { timer in
NavigationLink(destination: TimerView...
When a user taps an item in the list, I want to display the information associated with that RoundTimerModel in the TimerView:
struct TimerView: View {
// need to somehow get a single timer instance in here
let timerModel: RoundTimerModel
@State var timeRemaining: Int
@Bindable var roundTimer: RoundTimerModel
I cannot figure out how to get access to that single RoundTimerModel instance in the TimerView.
Can anyone help me out?
I have a CWC+ subscription, and I asked a question in the Chat this morning (as per the instructions) yet have had zero response. Is this typical?
@carriere4
Hi Charles,
Welcome to the community.
Bear in mind that Chris Ching and the team are based in Toronto so If you posted a message on the Chat method available in CWC+, ie via this…
…then depending on the time of the day there, it may have been that they were out or busy or whatever the case.
Probably best to post your question here since there is a better chance of getting someones attention given that there are a number of Moderators in different time zones.
Anyway regarding your question:
Is the RoundTimerModel
just a struct defining an instance of a RoundTimerModel
or is it an ObservableObject?
In this line of code:
ForEach (timers) { timer in
Is timers
an array of RoundTimerModel
?
Can you show more completely what the destination: TimerView.....
is. Are you intending to just pass timer
to TimerView? If so then declare a single variable in TimerView that relates to the parameter you intend to pass in.
ie:
let timerModel: RoundTimerModel
What do these two declarations do:
@State var timeRemaining: Int
@Bindable var roundTimer: RoundTimerModel