0

I am developing a mac application in Xcode 5.1. I would like to terminate the application when the close button is clicked inside the application. Check the link for the image.

The link is as follows http://tinypic.com/r/2yn070h/8.

There is a red button on top of the window. When I click the red button the application has to be terminated. The code for termination is as follows

[NSApp terminate:self];

2 Answers2

4

The only thing you have to do is implement this method in your AppDelegate:

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
    return YES;
}
Merlevede
  • 8,078
  • 1
  • 23
  • 39
-2

To exit your app use command exit(0).

lee
  • 7,535
  • 8
  • 43
  • 59