Escaping closure captures ‘inout’ parameter ‘selectedPassengerId’ in SwiftUI?

[ad_1]

I’m attempting to assign worth to property however getting bellow difficulty.

enter image description here

func buildClassViews(accessibilityID: String, information: Binding<[Passenger]>,  selectedPassengerId: inout String) -> [AnyView] {
    var views: [AnyView] = []
    @StateObject var viewModel: ViewModel
    
    for aspect in information {
        views.append(
            VStack {
                HStack {
                    VStack(alignment: .main, spacing: 0) {
                        Textual content(aspect.fullName.wrappedValue ?? "")
                        Spacer()
                    }
                    .onAppear(carry out: {
                        selectedPassengerId = "(aspect.passengerId)"  //
                    })
                }
                .convertToAnyView())
            }
        }
}

Tried few issues however not getting any clue….undecided what is that this difficulty and easy methods to resolve it.

[ad_2]

Leave a Reply