我试图将一个'acceptGesture'的可观察对象发送到一个viewmodel承包商。但是,xCode不断抛出错误'Type'inout UITapGestureRecognizer'不符合协议'ReactiveCompatible''
以下是我关注https://github.com/ReactiveX/RxSwift/tree/master/RxExample/RxExample/Examples/APIWrappers
的示例import UIKit
#if !RX_NO_MODULE
import RxSwift
import RxCocoa
#endif
class JobsViewController: UIViewController {
@IBOutlet weak var acceptClickableView: UIView!
@IBOutlet weak var acceptGesture: UITapGestureRecognizer!
private var viewModel: JobsViewModel!
private let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
initView()
viewModel = JobsViewModel()
let input = JobsViewModel.Input(acceptTrigger: self.acceptGesture.rx.event.asObservable())
}
}
import Foundation
#if !RX_NO_MODULE
import RxSwift
import RxCocoa
#endif
class JobsViewModel: ViewModelType {
struct Input {
let acceptTrigger: Observable<UITapGestureRecognizer>
}
struct Output {}
init(){}
func transform(input: Input) -> Output {
return Output()
}
}
答案 0 :(得分:0)
问题可能在于编译本身(xCode)....我删除了发送到ViewModel的参数...并重新编译。现在它正在运作......