Is user interface required in order to do global event monitoring in Cocoa?
问题 I have a simple snippet(not MVC) of code looking like the following # include <Cocoa/cocoa.h> int main(argc, *argv[]) { [NSApplication sharedApplication] [NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyUpMask handler:^(NSEvent *evt){ .... }] [NSApp run] } When compiled as command line binary and run, the global event monitoring works, after allowing the program from system preferences -> privacy & security; then I packed it int an .app, and ran it, the global monitor stopped working even