title: Link xib file with UIViewController and Custom Class
body: <p>To create the xib file I add a new cocoa touch file subclass of UIViewController, and checked the "Also Create XIB file". </p>
  
  <p>There is only one label in my xib file. </p>
  
  <p>In my view controller : </p>
  
  <pre><code>import UIKit
  
  class TestControllerViewController: UIViewController {
  
      @IBOutlet weak var label: UILabel!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          // Do any additional setup after loading the view.
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  </code></pre>
  
  <p>Nothing else than my IBoutlet (I checked the connection Inspector 10 times at least).</p>
  
  <p>And My custom class : </p>
  
  <pre><code>import Foundation
  import UIKit
  
  
  class Card: UIView {
      internal var number:Int?
  
      required init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
      }
  
      override init(frame: CGRect) {
          super.init(frame: frame)
  
      }
  
      convenience init()
      {
          self.init()
      }
  
  }
  
  extension UIView {
      class func loadFromNibNamed(nibNamed: String, bundle : NSBundle? = nil) -&gt; UIView? {
          return UINib(
              nibName: nibNamed,
              bundle: bundle
              ).instantiateWithOwner(nil, options: nil)[0] as? UIView
      }
  }
  </code></pre>
  
  <p>I instantiate this xib file in my initial viewController : </p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
          var test:Card = Card.loadFromNibNamed("TestControllerViewController")! as! Card
          test.number = 18
          //self.view.addSubview(test)
      }
  </code></pre>
  
  <p>And I still have this error : </p>
  
  <p><code>2015-07-27 17:48:52.919 TestXib[6865:578635] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[&lt;NSObject 0x7fcec14b1970&gt; setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key label.'</code></p>
  
  <p>I don't know why, I tried to clean / rebuild, delete DerivedData, create the xib file again etc. </p>
  
  <p>Could you please help me ? </p>
  
  <p>Thank's.
  Ben </p>