I have an environment object with two arrays of the same type, each array is @Published
In a View I want to show a list of one or the other array in a List, which array is chosen is set on showing the View
How do I tell the View which array to show?
Model contains:
I want to pick "a" or "b" when the view is shown, do I use @State or a @Binding or what?
In a View I want to show a list of one or the other array in a List, which array is chosen is set on showing the View
How do I tell the View which array to show?
Code Block @EnvironmentObject var model: Model
Code Block var body: some View { List { ForEach(model.a.indices) { index in ThingView( rowData: self.$model.a[index] ) } } }
Model contains:
Code Block @Published var a: [String] @Published var b: [String]
I want to pick "a" or "b" when the view is shown, do I use @State or a @Binding or what?