试图在 AppDelegate 中隐藏所有其他应用程序

Trying to HideAllOtherApplications in AppDelegate

我一直在尝试寻找一种方法来在我的 AppDelegate 中以编程方式隐藏其他应用程序。我试过了:

func hide() {
NSLog("hide")
NSApplication.hideOtherApplications(self)
}

The error seems to be in the "self". I am pretty sure it is a really simple error but I keep on having issues trying to work it out.

但这似乎不起作用。我是 OS X 编程的新手。虽然我已经用 swift.

做了一点(只是一点点)

我猜你正在寻找这个:

NSWorkspace.sharedWorkspace().hideOtherApplications()

NSApplication.sharedApplication().hideOtherApplications(self)

NSApplication.sharedApplication().unhideAllApplications(self)

NSWorkspace 没有 unhideAllApplications。请查看 Apple 网站的参考资料。