Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I quit a mac application programmatically?

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?

like image 857
Man of One Way Avatar asked Aug 08 '11 22:08

Man of One Way


People also ask

How do I programmatically quit my iOS application?

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.

How do you force quit an app?

On a PC: Press Ctrl+Alt+Delete to open task manager (or Ctrl+Shift+Esc to force quit).


1 Answers

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:.

enter image description hereenter image description here

like image 176
sidyll Avatar answered Oct 16 '22 03:10

sidyll