ios – Handle Binding String for TextField in ForEach


Hi all I am attempting to work with TextField inside a ForEach

I am having issues with the binding string that I’ve to place within the textual content parameter of the textField

I’ve a Supervisor class the place I’ve 2 strings which ought to be the textField binding within the ForEach

class Supervisor: ObservableObject {    
    @Printed var title: String = ""
    @Printed var handle: String = ""
    @Printed var metropolis: String = ""    
}

Now as you possibly can see within the struct Take a look at: View I do a ForEach on an array and return 3 TextFields however I am unable to work out how I can affiliate @Printed var title, @Printed var handle, @Printed var metropolis within the TextField of ForEach

struct Take a look at: View {
    var physique: some View {
       VStack {
       ForEach(Data.infos.indices, id:.self) { index in
            TextField("(Data.infos[index].title)", textual content: ???? )
        }
     }
   }
}

Can anybody level me the right method to obtain this?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles