title: Initialize a subclass of NSViewController without a xib file
body: <p>I am currently writing an OS X application using Swift 2. I am wanting to build the UI without XIBs or Storyboards. The problem I am having is on initializing a custom ViewController that I can put my views in.</p>
  
  <p>Here is my AppDelegate:</p>
  
  <pre><code>@NSApplicationMain
  class AppDelegate: NSObject, NSApplicationDelegate {
  
    @IBOutlet weak var window: NSWindow!
    var viewController: MyViewController?
  
    func applicationDidFinishLaunching(aNotification: NSNotification) {
      viewController = MyViewController()
      self.window.contentView!.addSubview(viewController!.view)
    }
  
    func applicationWillTerminate(aNotification: NSNotification) {
      // Insert code here to tear down your application
    }
  
  }
  </code></pre>
  
  <p>And MyViewController:</p>
  
  <pre><code>class MyViewController: NSViewController {
    var textField: NSTextField?
  
      override func viewDidLoad() {
        super.viewDidLoad()
  
        textField = NSTextField(frame: NSRect(x: 10, y: 10, width: 100, height: 100))
        textField!.bezeled = false
        textField!.drawsBackground = false
        textField!.editable = false
        textField!.selectable = false
        textField!.stringValue = "TEST"
        self.view.addSubview(textField!)
      }
  
  }
  </code></pre>
  
  <p>The problem is that when I add the <code>viewController</code>'s view as a subview of the window's <code>contentView</code>, I get the following error and the view doesn't load.</p>
  
  <pre><code>2015-12-06 17:34:18.204 Test[9682:1871784] -[NSNib 
  _initWithNibNamed:bundle:options:] could not load the nibName: 
  Test.MyViewController in bundle (null).
  </code></pre>
  
  <p>I'm not sure what I'm doing wrong - any help would be appreciated.</p>