title: Opening a new window in an OS X application with Swift
body: <p>I'm totally new to OS X application development and have some problem opening a new window from a status bar menu.</p>
  
  <p>I read several tutorials and tried to follow them. Since they don't exactly fit my project, I made some modifications but it doesn't seem to work.</p>
  
  <p>I have created a new subclass of NSWindowController in order to design some UIs. But when I click on the menu, no window appears.</p>
  
  <pre><code>//AppDelegate.Swift
  
  import Cocoa
  
  @NSApplicationMain
  class AppDelegate: NSObject, NSApplicationDelegate {
  
      let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-2)
  
      @IBOutlet weak var window: NSWindow!
  
      func applicationDidFinishLaunching(aNotification: NSNotification) {
          // Insert code here to initialize your application
          if let button = statusItem.button {
              button.image = NSImage(named: "StatusBarButtonImage")
          }
  
          let menu = NSMenu()
  
          menu.addItem(NSMenuItem(title: "About MyProgram", action: Selector("getAbout:"),keyEquivalent: ""))
  
          statusItem.menu = menu
  
      }
  
      // open "About MyProgram" window
      func getAbout(sender: AnyObject) {
          let controller = AboutWindowController()
          controller.showWindow(self)
      }
  
      func applicationWillTerminate(aNotification: NSNotification) {
          // Insert code here to tear down your application
      }
  
  
  }
  </code></pre>
  
  <p>I didn't know what to write in the new class, so I left it as it was created by default.</p>
  
  <pre><code>//AboutWindowController.swift
  import Cocoa
  
  class AboutWindowController: NSWindowController {
  
      override func windowDidLoad() {
          super.windowDidLoad()
  
          // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
      }
  
  }
  </code></pre>
  
  <p>Any help is appreciated! Thanks!</p>