title: Class written in Swift cannot be a Nib Owner (Crash)
body: <p><em>Here is what I am trying to do:</em> Design a view in a nib file. Back the view and nib owner with classes written in Swift. Instantiate nib's view in Swift. Code that crash:</p>
  
  <pre><code>var myViewOwner: MyViewOwner?
  NSBundle.mainBundle().loadNibNamed("MyView", owner: myViewOwner, options: nil) // crash
  </code></pre>
  
  <p>... with error: </p>
  
  <blockquote>
    <p>[NSObject 0x7bfa0cc0 setValue:forUndefinedKey:]: this class is not
    key value coding-compliant for the key myView.</p>
  </blockquote>
  
  <p>So, I have: nib file with blank view where view is of type <code>MyClass</code> and nib owner of type <code>MyViewOwner</code>. Both classes written in Swift.</p>
  
  <h2>What I already tried (Initial attempt):</h2>
  
  <p>I will be posting only MyViewOwner class code since MyView.swift is just a class definition.</p>
  
  <p><strong>MyViewOwner.swift</strong></p>
  
  <pre><code>class MyViewOwner {
      @IBOutlet weak var myView: MyView
  }
  </code></pre>
  
  <p>Caused error above.</p>
  
  <h2>2-nd attempt with NSObject:</h2>
  
  <p>Of course Swift objects are not KVO compliant, so I tried:</p>
  
  <pre><code>class MyViewOwner: NSObject {
      @IBOutlet var myView: MyView
  }
  </code></pre>
  
  <p>... and:</p>
  
  <pre><code>class MyViewOwner: NSObject {
      @IBOutlet strong var myView: MyView = MyView() // we need to set something since it's 'strong'
  }
  </code></pre>
  
  <p>Both caused error above.</p>
  
  <h2>3-rd attempt with @objc annotation:</h2>
  
  <pre><code>@objc class MyViewOwner: NSObject {
      @objc @IBOutlet strong var myView: MyView = MyView()
  }
  </code></pre>
  
  <p>Didn't helped either, same error.</p>
  
  <p>What I am doing wrong? In what way should I write all code in swift to make it work?</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong> Owner and View setup in xCode</p>
  
  <p><img src="https://i.stack.imgur.com/Jhs92.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/nOTqt.png" alt="enter image description here"></p>
  
  <p><strong>UPDATE:</strong> Owner to View connection</p>
  
  <p><img src="https://i.stack.imgur.com/pL0Xz.png" alt="enter image description here"></p>