title: Init for a SwiftUI class with a @Binding var
body: <p>I have a class which I want to initialize with a Binding var that is set in another View.</p>
  <p>View -&gt;</p>
  <pre><code>struct CoverPageView: View {
      @State  var numberOfNumbers:Int
  
      var body: some View {
          NavigationView {
              GeometryReader { geometry in
                  VStack(alignment: .center, spacing: 0){
                      TextField(&quot;Multiplication Upto:&quot;, value: self.$numberOfNumbers, formatter: NumberFormatter())
  
                  }
              }
          }
      }
  </code></pre>
  <p>CLASS WHICH NEEDS TO BE INITIALIZED USING THE @Binding var $numberofNumbers -</p>
  <pre><code>import SwiftUI
  
  class MultiplicationPractice:ObservableObject {
  
      @Binding var numberOfNumbers:Int
      var classNumofNumbers:Int
  
      init() {
          self.classNumofNumbers = self.$numberOfNumbers
      }
  }
  </code></pre>
  <p>The init statement obviously gives the error that self is not initialized and the instance var is being used to initialize which is not allowed.</p>
  <p>How do I circumvent this? The class needs to be initialized with the number the user enters on the first view. I have written approx. code here so ignore any typos please.</p>