title: Show hidden window in OS X Swift app
body: <p>I'm developing a simple menubar app for OS X Yosemite using Swift.
  What is I need is to show Preferences window (when user clicks on menu item)
  Window should be hidden at launch, and should be shown when user calls it.</p>
  
  <p>I found an example which implements the same thing that I need: <a href="http://www.johnmullins.co/blog/2014/08/08/menubar-app/" rel="nofollow">http://www.johnmullins.co/blog/2014/08/08/menubar-app/</a></p>
  
  <p>This is a piece of code from my app:  </p>
  
  <pre><code>class AppDelegate: NSObject, NSApplicationDelegate {
      @IBOutlet weak var buildStatusMenu: NSMenu!
      @IBOutlet weak var preferencesWindow: NSWindow!
  
      let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1)
      func applicationDidFinishLaunching(aNotification: NSNotification) {
          self.preferencesWindow!.orderOut(self)
      }  
  
      func showPreferencesWindow(sender: AnyObject?) {
          self.preferencesWindow!.orderFront(self)
          NSLog("Show window")
      }
  </code></pre>
  
  <p>orderOut works correctly, and I don't see window at launch but when I try to call showPreferencesWindow(), nothing happens. (But I see a record in log)
  I'm sure there is no magic here, I'm just doing something wrong.
  Can someone help me? Thanks in advance.</p>