I want to create a certain amount of TextFields on a view based on the number the user inputs. For Example, if the user inputs 5 I would like to display 5 TextFields on the view. I was thinking about using "Form" with a "For Each," but I cant figure out the correct syntax or if it's possible at all. This is my code so far:
struct NameView: View{
@Binding var numNames: String
@State private var newSet = []
var body: some View{
var numNameInt = Int(numNames)
Form{
ForEach(newSet) { index in
TextField("Name", text: $newSet[index])
}
}
}
Any help would be appreciated.