当我切换应用程序时,我的函数没有被执行:
public class ItemObserver: NSObject {
@objc public func recievedNotification(notification: NSNotification) {
print(notification.name)
print("s")
}
}
let observer = ItemObserver()
NSWorkspace.shared().notificationCenter.addObserver(observer, selector: #selector(ItemObserver.recievedNotification(notification:)), name: .NSWorkspaceDidActivateApplication, object: nil)https://stackoverflow.com/questions/44468795
复制相似问题