rac_signalForSelector fromProtocol,选择器不存在

rac_signalForSelector fromProtocol, selector does not exist

我正在尝试使用响应式包装 WKWebViewDelegate Cocoa。

class WebContainerView: UIView, WKNavigationDelegate
{
let webView:WKWebView

required init(coder aDecoder: NSCoder){
    webView = WKWebView(frame: CGRect())
    super.init(coder: aDecoder)
    self.addSubview(webView)

    let proto = WKNavigationDelegate.self
    let selector:Selector = "webView(_:decidePolicyForNavigationAction:decisionHandler:)"
    let signal =   webView.rac_signalForSelector(selector, fromProtocol: proto).subscribeNext( { _ in
        println("Test")
    })
    webView.navigationDelegate = self
}}

但是我在创建信号时遇到了这个错误

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Selector webView(_:decidePolicyForNavigationAction:decisionHandler:) does not exist in <WKNavigationDelegate>'

选择器名称正是在委托方法中调用它的输出:

NSLog(%@, "__FUNCTION__")

我找到了这个错误的解决方案,就是改变了这一行:

let selector:Selector = "webView(_:decidePolicyForNavigationAction:decisionHandler:)"

对此:

let selector:Selector = "webView:decidePolicyForNavigationAction:decisionHandler:"