Reputation: 23
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];
Upvotes: 1
Views: 1834
Reputation: 8180
The only thing you have to do is implement this method in your AppDelegate:
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
return YES;
}
Upvotes: 5