Starting with a code example :
struct SomeListView: View {
@Binding var data: Data
var body: some View {
List{
Section{
//Here's the rub, to take advantage of onDelete I'm using this method
ForEach(data.arr[0], id: \.self) { item in
// which works great for display
Text(item[2])
// but because item is an array
TextField("FieldName", text: item[0])
// calls an error ... you probably guessed it. Right. Cannot convert String to Binding String kinda thing ... to add a pickle to the picnic, another string within that array I want to bind to gets passed to a string to bool value function that requires the binding
//The question is pretty basic ... how to aquire the index number of the desired string so I can do something like this
ForEach(data.array[0], id: \.self) { item in
//aquire index num or loop count to use as index ????
TextField("FieldName", text: $data.arr[0][index][0])
TextField("FieldName", text: $data.arr[0][index][1])
CheckBoxFromString(isSetString: $data.arr[0][index][2])
}
.onDelete { indices in
data.arr[0].remove(atOffsets: indices)
}
}
}
}
Apologies for vagueness and ambiguity or if this just seems blindingly obvious. I'm fairly fresh to Swift, SwiftUI etc ... it's a learning curve. Appreciate any tips Cheers