gpt4 book ai didi

swift - ReactiveCocoa 对成员 RACSignal 的引用不明确

转载 作者:行者123 更新时间:2023-11-30 13:29:14 26 4
gpt4 key购买 nike

我正在尝试返回一个可以在 Objective-C 代码中使用的 RACSignal,我尝试了各种方法。例如:

@objc
class func getPosts() -> RACSignal {
let (signal, observer) = Signal<String, NSError>.pipe()
return signal.toRACSignal()
}

也是这样。

@objc
class func getPosts() -> RACSignal {
return SignalProducer {
observer, disposable in
}.toRACSignal()
}

但是 XCode 总是说相同的:

ambiguous reference to member toRACSignal

我的 podfile 看起来像这样:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'Bebler' do
pod 'ComponentKit', '= 0.14'
pod 'ReactiveCocoa', '~> 4.1.0'
pod 'AFNetworking', '~> 3.1'
pod 'Alamofire', '~> 3.3'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
pod 'KeychainSwift', '~> 3.0'
end

我的 Xcode 版本为 7.3

也尝试过这个:

@objc
class func getPosts() -> RACSignal {
let signalProducer: SignalProducer<String, NSError> = SignalProducer {
observer, disposable in
}
return signalProducer.toRACSignal()
}

相同的结果。

最佳答案

你可以这样尝试:(可选)

@objc
class func getPosts() -> RACSignal? {
if let (signal, observer) = Signal<String, NSError>.pipe() as? Signal! {
return signal.toRACSignal()
}
return nil
}

关于swift - ReactiveCocoa 对成员 RACSignal 的引用不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36769988/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com