4

I'm a little bit new to Objective-c with xCode, and I would like to know something. Is there a way to terminate an application when the red circle in the left of the window is clicked? Like on the calculator.

iain
  • 5,660
  • 1
  • 30
  • 51
TheNerdyCoder
  • 184
  • 1
  • 10

2 Answers2

23

Yes you can do with Mac OSX applications.

You need to implement this method in your AppDelegate class

 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender{
    return YES;
}
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
1

If you want terminate the app when closing the window. Please implement the following appdelegate method.

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
    {
        return YES;
    }

If you want do not terminate your app, just set the return "NO".

I hope that your problem will be resolved with this solution.

Rakesh
  • 3,370
  • 2
  • 23
  • 41
Amit Singh
  • 2,644
  • 21
  • 20