title: SwiftUI TextField Number Input
body: <p>I'm trying to have the user input two numbers and then have those numbers be displayed and also added together.  At the moment in order for the state variable to be updated you have the press return.  Is there a way to have the state update like it does with text?  I also have had the code inputed as a string but haven't been able to convert that to int so the numbers can be added together correctly. If anyone knows how to have it convert properly I would appreciate all the help I can get.</p>
  <pre><code>struct ContentView: View {
      @State private var numOne: Int = 0
      @State private var numTwo: Int = 0
  
      var body: some View {
          NavigationView {
              VStack {
                  Form {
                      Section {
                          TextField(&quot;Number One&quot;, value: $numOne, formatter: NumberFormatter())
                              .keyboardType(.numberPad)
  
                          TextField(&quot;Number Two&quot;, value: $numTwo, formatter: NumberFormatter())
                              .keyboardType(.numberPad)
                      }
  
                      NavigationLink(
                          destination: addedView(numOne: $numOne, numTwo: $numTwo),
                          label: {
                              Text(&quot;Navigate&quot;)
                          }
                      )
                  }
              }
          }
      }
  }
  
  struct addedView: View {
      @Binding var numOne: Int
      @Binding var numTwo: Int
      @State private var added: Int = 0
  
      var body: some View {
          VStack {
              Text(&quot;\(numOne)&quot;)
              Text(&quot;\(numTwo)&quot;)
          }
      }
  }
  </code></pre>