NSNotification.Name.didBecomeActiveNotification 未找到
NSNotification.Name.didBecomeActiveNotification not found
我正在 Xcode 10.1 上使用 10.14 部署目标开发 macOS 应用程序。根据文档,应该有 NSNotification.Name.didBecomeActiveNotification,但构建失败并出现 Type 'NSNotification.Name?' has no member 'didBecomeActiveNotification'
错误。我导入了 Cocoa、AppKit 和 Foundation。相关代码如下:
NotificationCenter.default.addObserver(forName: .didBecomeActiveNotification, object: nil, queue: nil) { notification in
print("\(notification)")
}
有什么问题?
现在是 class 属性 的 NSApplication
NotificationCenter.default.addObserver(forName: NSApplication.didBecomeActiveNotification, object: nil, queue: nil) { notification in
我正在 Xcode 10.1 上使用 10.14 部署目标开发 macOS 应用程序。根据文档,应该有 NSNotification.Name.didBecomeActiveNotification,但构建失败并出现 Type 'NSNotification.Name?' has no member 'didBecomeActiveNotification'
错误。我导入了 Cocoa、AppKit 和 Foundation。相关代码如下:
NotificationCenter.default.addObserver(forName: .didBecomeActiveNotification, object: nil, queue: nil) { notification in
print("\(notification)")
}
有什么问题?
现在是 class 属性 的 NSApplication
NotificationCenter.default.addObserver(forName: NSApplication.didBecomeActiveNotification, object: nil, queue: nil) { notification in