1

I need to close the entire app when the user click on a Panel close button, I tried:

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

but it closes the app also from file-selector panels.

Thank you in advance. L.

fntlnz
  • 411
  • 2
  • 6
  • 14

1 Answers1

2

Applications can't be closed, only quit. Only windows can be closed, not applications.

If you want to quit the application when only a specific window is closed, be that window's delegate and respond to the windowWillClose: message by telling the application to terminate.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • 1
    Thank you so much! :) I Solved adding `- (void)windowWillClose:(NSNotification *)notification { [NSApp terminate:nil]; }` and setting App Delegate as delegate in Outlets. – fntlnz Dec 29 '12 at 04:40