I need to add a quit-button to my application that runs from the menubar in mac. How do I programmatically quit an application in mac?
An iOS app never displays a Close or Quit option. People stop using an app when they switch to another app, return to the Home screen, or put their devices in sleep mode. Never quit an iOS app programmatically.
On a PC: Press Ctrl+Alt+Delete to open task manager (or Ctrl+Shift+Esc to force quit).
There is a simpler form to quit from code:
[NSApp terminate:self];
But as you're adding a button, all you have to do is to control drag from your button to the Application icon and connect the method terminate:
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With