title: How to pass binding to subview with SwiftUI when the variable is nested in an object?
body: <p>This works</p>
  
  <pre><code>import SwiftUI
  struct ContentView : View {
      @State var val1: Int = 0
      var body: some View {
          MySubview(val1: $val1)
      }
  }
  
  #if DEBUG
  struct ContentView_Previews : PreviewProvider {
      static var previews: some View {
          ContentView(val1: 0)
      }
  }
  #endif
  
  struct MySubview : View {
      @Binding var val1: Int
      var body: some View {
          return Text("Value = \(val1)")
      }
  }
  </code></pre>
  
  <p>But when the variable is nested in an Object, this fails</p>
  
  <pre><code>import SwiftUI
  struct MyStruct {
      let number: Int
  }
  
  struct ContentView : View {
      @State var val1 = MyStruct(number: 7)
      var body: some View {
          MySubview(val1: $val1.number)
      }
  }
  
  #if DEBUG
  struct ContentView_Previews : PreviewProvider {
      static var previews: some View {
          ContentView(val1: 0)
      }
  }
  #endif
  
  struct MySubview : View {
      @Binding var val1: Int
      var body: some View {
          return Text("Value = \(val1)")
      }
  }
  </code></pre>
  
  <p>Error shown: <code>Generic parameter 'Subject' could not be inferred</code></p>
  
  <p>How do i pass nested variable as a binding to a subview?</p>