Reputation: 48490
An example method signature from WKWebView:
func evaluateJavaScript(_ javaScriptString: String,
completionHandler: ((Any?, Error?) -> Void)? = nil)
How does one correctly implement this method to be able to capture the Any?
and Error?
arguments in the completionHandler closure? I want to be able to use both of them in a print
statement for instance. I can't seem to get the syntax correct for the implementation, though.
Upvotes: 0
Views: 42
Reputation: 54640
evaluateJavaScript(javaScriptString: yourString, completionHandler: { result, error in
if let error = error {
print("error: \(error)")
}
if let result = result {
print("result: \(result)")
}
// Your code here
})
Upvotes: 3