- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender{
return YES;
}
方法二:
NSButton *closeButton = [self window] standardWindowButton:NSWindowCloseButton];
[closeButton setTarget:self];
[closeButton setAction:@selector(closeApplication)];
- (void) closeApplication {
[NSApplication sharedApplication] terminate:nil];
}