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.
EvaluateJavaScript(NSString, WKJavascriptEvaluationResult)Evaluates the given JavaScript string.
A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app's UI. A web view supports a full web-browsing experience, and presents HTML, CSS, and JavaScript content alongside your app's native views.
https://developer.apple.com/reference/webkit/wkwebview/1415017-evaluatejavascript?language=objc
The completion handler always runs on the main thread.
Almost at the very end of the page. Possibly added sometime after you posted this question.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With