Question

I'm not sure which is the right way, right now I'm just calling exit(0) when a user clicks on the exit button.

Was it helpful?

Solution

Use NSApplication's terminate method. For example:

[NSApp terminate:self]

Documentation is available here.

OTHER TIPS

The previously given answer is deprecated since 10.10 and this question is the first thing that turns up for cocoa quit application, so use this instead (Swift):

NSApplication.sharedApplication().terminate(self)

Note: As of now it's the following:

NSApplication.shared().terminate(self)

I always terminate App the safe way.

[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0];

This will put the event in the next loop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top