Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否有办法编写一个监听 OS 系统事件的 Cocoa 应用程序,例如应用程序启动、窗口切换等。我的想法是观看 [NSNotficationCenter default] 的消息,但到目前为止我还没有没能找到很多。有没有人有什么建议?
谢谢!
一些您可能感兴趣的消息将被提供给[NSWorkspace notificationCenter],例如应用程序启动时、出现在前面或退出时。
[NSWorkspace notificationCenter]
我不确定您所说的“窗口开关”是什么意思。如果您的意思是更改前面的窗口而不更改前面的应用程序,那么在 Mac 上通常认为“不关您的事”。