Mel*_*ius 1 macos nsnotifications notificationcenter swift
我正在 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)")
}
Run Code Online (Sandbox Code Playgroud)
问题是什么?
它现在是一个类属性 NSApplication
NotificationCenter.default.addObserver(forName: NSApplication.didBecomeActiveNotification, object: nil, queue: nil) { notification in
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1178 次 |
| 最近记录: |