title: Use Binding<Int> with a TextField SwiftUI
body: <p>I am currently building a page to add player information to a local database. I have a collection of TextFields for each input which is linked to elements in a player struct.</p>
  
  <pre><code>var body: some View {
          VStack {
              TextField("First Name", text: $player.FirstName)
                  .textFieldStyle(RoundedBorderTextFieldStyle())
              TextField("Last Name", text: $player.LastName)
                  .textFieldStyle(RoundedBorderTextFieldStyle())
              TextField("Email", text: $player.eMail)
                  .textFieldStyle(RoundedBorderTextFieldStyle())
              TextField("Shirt Number", text: $player.ShirtNumber)
                  .textFieldStyle(RoundedBorderTextFieldStyle())
              TextField("NickName", text: $player.NickName)
              .textFieldStyle(RoundedBorderTextFieldStyle())
              TextField("Height", text: $player.Height)
                  .textFieldStyle(RoundedBorderTextFieldStyle())
              TextField("Weight", text: $player.Weight)
                  .textFieldStyle(RoundedBorderTextFieldStyle())
  
              Button(action: {
                  submitPlayer(player: self.player)T
              }) {
                  Text("Submit")
              }
  
              Spacer()
          }
      }
  </code></pre>
  
  <p>My player struct is</p>
  
  <pre><code>struct Player: Hashable, Codable, Identifiable {
      var id: Int
      var FirstName: String
      var LastName: String
      var NickName: String
      var eMail: String
      var ShirtNumber: Int
      var Height: Int
      var Weight: Int
  }
  </code></pre>
  
  <p>The issue is that ShirtNumber, Height, and Weight are all Int values. When I bind them to the TextField I get an error saying <code>Cannot convert value of type 'Binding&lt;Int&gt;' to expected argument type 'Binding&lt;String&gt;'</code>. Everything I have looked into about SwiftUI says it's impossible to have a TextField with an Int value bound to it. </p>
  
  <p>My question is, would it be possible to create a new class that extends TextField but allows for only Int inputs and that binds an Int variable, something like this?</p>
  
  <pre><code>struct IntTextField: TextField {
  
      init(_ text: String, binding: Binding&lt;Int&gt;) {
  
      }
  }
  
  </code></pre>
  
  <p>So far all I have been able to find is an answer to part of my question (accepting only Int input) from <a href="https://stackoverflow.com/questions/57822749/how-to-create-swiftui-textfield-that-accepts-only-numbers-and-a-single-dot">this</a> question. I am looking for a way to combine this with the <code>Binding&lt;Int&gt;</code>.</p>
  
  <p>Thanks for the help.</p>