【问题标题】:IOS 13 Combine Framework - @Published not working ("Unknown attribute 'Published'")IOS 13 组合框架 - @Published 不起作用(“未知属性'已发布'”)
【发布时间】:2019-06-10 07:31:14
【问题描述】:

我观看了 WWDC 2019 会议“Combine in Practice”(https://developer.apple.com/videos/play/wwdc2019/721/)。

在视频中,他们使用以下语法创建发布者:

@Published var someName: String = ""

他们这样做是为了让someName 成为发布者。但是,Xcode 不喜欢这种语法并给我一个错误:

未知属性“已发布”

我不知道为什么。我在 macOS Catalina 上使用 Xcode 11 测试版。

有什么想法吗?

【问题讨论】:

    标签: ios swift combine


    【解决方案1】:

    来自Xcode 11 Beta Release Notes(强调添加):

    Combine 框架的 Foundation 集成不可用。以下 Foundation 和 Grand Central Dispatch 与 Combine 的集成不可用: KeyValueObserving、NotificationCenter、RunLoop、OperationQueue、Timer、URLSession、DispatchQueue、JSONEncoder、JSONDecoder、PropertyListEncoder、PropertyListDecoder 和 @Published 属性包装器。 (51241500)


    更新: Xcode 11 beta 2 已修复此问题。来自Xcode 11 Beta 2 Release Notes

    已解决的问题

    Combine 框架的 Foundation 集成现已推出。以下 Foundation 和 Grand Central Dispatch 与 Combine 的集成可用:KeyValueObserving、NotificationCenter、RunLoop、OperationQueue、Timer、URLSession、DispatchQueue、JSONEncoder、JSONDecoder、PropertyListEncoder、PropertyListDecoder 和 @Published 属性包装器。 (51241500)

    【讨论】:

    • 好吧,这很奇怪。在会议中,他们字面意思是说你现在就可以开始了。不过谢谢!
    • @silicon_valley:感谢您告诉我们!
    【解决方案2】:

    在 Xcode 11 beta 2 中可用,但必须导入 Combine

    【讨论】:

      猜你喜欢
      • 2020-08-21
      • 1970-01-01
      • 1970-01-01
      • 2020-07-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多