title: Dynamic TextFields based on user input using SwiftUI
body: <p>I am trying to create a dynamic set of TextFields which are added after the user presses the add button. Each press will add another set of those fields. I am new to this so please bear with me. I am getting a fatal error: index out of range. Here is a simple example of what I am trying to achieve. </p>
  
  <pre><code>struct ContentView: View {
  
      @State var name: [String] = []
      @State var counter = 0
  
      var body: some View {
          Form {
              Section {
                  ForEach(0..&lt;counter, id: \.self) { index in
                      TextField("Name", text: self.$name[index])
                  }
  
  
                  Button(action:{
                      self.counter += 1
                  }) {
                      Text("Add more")
                  }
              }
          }
      }
  }
  </code></pre>