I'm trying to wrap WKWebViewDelegate using Reactive 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
}}
However I get this error upon creating the signal
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Selector webView(_:decidePolicyForNavigationAction:decisionHandler:) does not exist in <WKNavigationDelegate>'
The selector name is exactly the output calling this in the delegate method:
NSLog(%@, "__FUNCTION__")
I figured out the solution to this error, which was changing this line:
let selector:Selector = "webView(_:decidePolicyForNavigationAction:decisionHandler:)"
to this:
let selector:Selector = "webView:decidePolicyForNavigationAction:decisionHandler:"