swift - How to reopen the window of app, Xcode -


i reading "cocoa programming os x" (the big neard ranch guid) , have made simplest application test empty windows app window controller , xib file controller. have wrote necessary code according book after building app , closing window of app cannot reopen window of app. wrong ? below code. (i deleted window in mainmenu.xib , accordingly changed appdelegate; , visible @ launch box unchecked) ). book says showwindow(_:) reopen window, don't see !

import cocoa   @nsapplicationmain  class appdelegate: nsobject, nsapplicationdelegate {  var control: control?  func applicationdidfinishlaunching(anotification: nsnotification) {      //create window controller object     let control = control()      //put window of window controler om screen     control.showwindow(self)      //set propertity point window controler     self.control = control  }   func applicationwillterminate(anotification: nsnotification) {     // insert code here tear down application }   } 

in controller class

import cocoa class control: nswindowcontroller {     override var windownibname: string?         {             return "control" } } 

in file's owner identity control controller , window has been connected window outlet.

you have add following application delegate method.

func applicationshouldhandlereopen(sender: nsapplication, hasvisiblewindows flag: bool) -> bool {     if flag {         control.window.orderfront(self)     } else {         control.window.makekeyandorderfront(self)     }     return true } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -