Stopping the NSApplication main event loop
问题 I have an application consisting of the following single .m file: #import <Cocoa/Cocoa.h> int main(int argc, char* argv[]) { [[[NSThread alloc] initWithBlock: ^{ sleep(2); dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@"Stop"); [[NSApplication sharedApplication] stop:nil]; }); }] start]; [[NSApplication sharedApplication] run]; NSLog(@"Run finished"); return 0; } According to the developer documentation, stop should stop the main loop ( run ), but it doesn't (at least not on OS X 10.12