I am creating an OSX app with swift version 2.2. I need to execute a method when the user clicking the close button on top left corner of my app, I am new in Cocoa programming anyone now which is the event executing when clicking close button (see the image).
My purpose is when i keep my app on dock it is not open after clicking close button(the black dot under app is showing after clicking close button), but in a case right click and force quit on it then clicking app on dock it will re open fine. I think by giving the below given code inside close button event will solve my problem.
NSApplication.sharedApplication().terminate(self)