title: @propertywrapper in SwiftUI
body: <p>I created a @propertyWrapper to limit the number a variable can reach. I tried it in a SwiftUI view with a button that increases the value of the variable and it works, the variable stops at the maximum number set in the initializer. However if I try it with a Textflied it doesn't work, if I insert a higher number than the one set nothing happens, it makes me do it. How can I solve this problem, I know the problem has to do with Binding but I don't know exactly what it is, here is the code:</p>
  <pre><code>import SwiftUI
  
  struct ContentView: View {
      
      @Maximum(maximum: 12) var quantity: Int
      
      var body: some View {
          NavigationView{
              Form{
                  TextField(&quot;&quot;, value: $quantity, format: .number, prompt: Text(&quot;Pizza&quot;).foregroundColor(.red))
                  
                  Button {
                      quantity += 1
                  } label: {
                      Text(&quot;\(quantity)&quot;)
                  }
              }
          }
      }
  }
  
  @propertyWrapper
  struct Maximum&lt;T: Comparable&gt; where T: Numeric {
      @State private var number: T = 0
  
      var max: T
  
      var wrappedValue: T {
          get { number }
          nonmutating set { number = min(newValue, max) }
      }
      
      var projectedValue: Binding&lt;T&gt; {
          Binding(
              get: { wrappedValue },
              set: { wrappedValue = $0 }
          )
      }
      
      init(maximum: T){
          max = maximum
      }
  }
  
  extension Maximum: DynamicProperty {
      
  }
  </code></pre>