This is probably so easy, as easy as checking a box in IB even. Anyway, I would like a way to make my Cocoa applications close button (the red button in the top left) quit the application like with System Preferences 😎.
So what you need to do first is have the window you want to close be connected to an IBOutlet in the nib. For this example i connected the window to an outlet named "mainWindow".
what this code does is overwrite the window closing action and tells it to quit instead. you do not need to add the "windowWillClose:" method to your header file.
Thanks a lot 🙂 got it working fine with both methods, though I did the delegation in Interface Builder rather than programatically (just seemed like the right thing to do 😉).
Anyway, Is there a way to set NSApp's delegate from Interface Builder too or not?