我需要观察https://developer.apple.com/documentation/passkit/pkpasslibrarynotificationname中指定的.PKPassLibraryDidChange和.PKPassLibraryRemotePaymentPassesDidChange通知,>
但是它们不是NSNotification.Name的子类,所以
let observer = NotificationCenter.default.addObserver(forName: PKPassLibraryNotificationName.PKPassLibraryDidChange, object: nil, queue: nil) { notification in ... }
不编译。
是否需要进行其他导入才能在NotificationCenter上观察PKPassLibraryNotificationName
?
[我需要观察https://developer.apple.com/documentation/passkit / ...中指定的.PKPassLibraryDidChange和.PKPassLibraryRemotePaymentPassesDidChange通知]
let notification = NSNotification.Name(rawValue: PKPassLibraryNotificationName.PKPassLibraryDidChange.rawValue)
NotificationCenter.default.addObserver(forName: notification, object: myPassLibrary, queue: nil) { (notification) in
// do something here
}