weiyin weiyin - 1 year ago 106
iOS Question

What thread does the completionHandler of WKWebView's evaluateJavascript method run on?

I am trying to figure out if it is safe to manipulate UI objects in the completion handler of WKWebView's

- evaluateJavaScript:completionHandler:
. The docs do not seem to specify.

Answer Source

It does not matter. If it is not specified then you should assume that it is not.

You can very easily run your UI code on the main thread using:

dispatch_async(dispatch_get_main_queue(), ^{
    // Your UI code here

Better safe than sorry.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download