Skip to content

Instantly share code, notes, and snippets.

@jaywcjlove
Last active December 29, 2015 15:19
Show Gist options
  • Save jaywcjlove/7689832 to your computer and use it in GitHub Desktop.
Save jaywcjlove/7689832 to your computer and use it in GitHub Desktop.
//点击关闭按钮关闭应用程序代理方法
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender{
return YES;
}
@jaywcjlove
Copy link
Author

//点击关闭按钮关闭应用程序
NSButton *closeButton = [[self window] standardWindowButton:NSWindowCloseButton];
[closeButton setTarget:self];
[closeButton setAction:@selector(closeApplication)];
  • (void) closeApplication {
    [[NSApplication sharedApplication] terminate:nil];
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment