我正在尝试将新的Combine框架与通知中心一起使用,如Apple在此视频中所述:https: //developer.apple.com/videos/play/wwdc2019/721/
您可以在幻灯片21中找到它。
看来我的项目没有阅读Combine框架api。
import Combine
import Foundation
let trickNamePublisher = NotificationCenter.default.publisher(for: .newTrickDownloaded)
Run Code Online (Sandbox Code Playgroud)
而且我收到此错误:
类型'NotificationCenter'的值没有成员'publisher'
显然,在Xcode 11 beta中似乎存在此已知问题:
Combine框架的Foundation集成不可用。 以下与Combine相结合的Foundation和Grand Central Dispatch集成不可用:KeyValueObserving,NotificationCenter,RunLoop,OperationQueue,Timer,URLSession,DispatchQueue,JSONEncoder,JSONDecoder,PropertyListEncoder,PropertyListDecoder和@Published属性包装器。(51241500)
链接:https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_release_notes/
实际上,他们在演示过程中没有使用Xcode,而只是在幻灯片上进行编码