piro299
piro299

Reputation: 25

NavigationDestination "in" variable as Binding in destination view not possible, why?

I did some searching but didn't understand the answer and I hope, I can ask the question again and get some help to find a solution.

I have a LazyVGrid with a NavigationLink inside and I would like to do that.

@State private var trainings = [TrainingData]()

LazyVGrid(columns: columns, spacing: columnVSpace) {
                        
    ForEach(trainings, id: \.id) {training in
    
        NavigationLink(value: training) {
        
            TrainingItemViewiPad(training: $training, trainings: $trainings) // => here is the issue, please see screenshot
        }
    }
}

struct TrainingItemViewiPad: View {
    
   @Binding var training: TrainingData
   @Binding var trainings: [TrainingData]

}

issue

Here is my navigationDestination with the same issue.

.navigationDestination(for: TrainingData.self) { training in
    TrainingDetailViewiPad(training: $training, trainings: $trainings) // => here is the issue, please see screenshot
}

struct TrainingDetailViewiPad: View {
    
    @Binding var training: TrainingData

}

issue

Is there a way to use @Binding as shown?

Many thanks advance, Sven

Upvotes: 0

Views: 13

Answers (0)

Related Questions