【问题标题】:Use of undeclared type 'SignalProducerType使用未声明的类型'SignalProducerType
【发布时间】:2018-08-03 10:31:42
【问题描述】:

我是 ReactiveCocoa 和 ReactiveSwift 的新手, 更新代码后,我有将代码从 Swift2 更新到 Swift4 的任务,我遇到了“未找到使用未声明类型'SignalProducerType'”的错误,我们有什么替代方法吗? 请帮我解决这个问题 我正在使用 ReactiveCocoa 7.1.0

扩展 SignalProducerType where Value == HTTPOperationResult,Error == APIError {

    func serializeToJSON() -> SignalProducer {
        返回尝试映射{结果
            守卫让数据=结果。数据其他{
                返回 .failure(APIError.parseError("invalid json"))
            }
            守卫让 JSON = 试试? JSONSerialization.jsonObject(with: data, options: []) else {
                返回 .failure(APIError.parseError("invalid json"))
            }
            返回 .success((结果,JSON))
        }
    }
}

【问题讨论】:

  • 包括你的代码..你对问题的描述就像超级模糊..
  • 编辑了我的问题
  • 好吧,显然SignalProducerType 不是一个公认的类型.. 你有那个类吗?
  • 不,我没有那门课
  • 你一定是在链接/导入 React 时破坏了某些东西,或者 API 发生了更改,重命名为 SignalProducerType..

标签: ios swift reactive-cocoa reactive-swift


【解决方案1】:

SignalProducerType 不再存在。它已重命名为SignalProducerProtocol,但不再用于添加运算符。 This ought to just be an extension on SignalProducer itself:

所有 Signal 和 SignalProducer 运算符现在都属于各自的具体类型。 (#304)

自定义运算符应直接扩展具体类型。 SignalProtocol 和 SignalProducerProtocol 应仅用于约束关联类型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-01
    • 2017-12-27
    • 2017-02-21
    • 2018-12-28
    • 2015-04-15
    • 2017-07-09
    相关资源
    最近更新 更多