How would I go about changing the value of a Swift variable based on a JavaScript variable? (Passing a JavaScript variable to Swift)
My goal is simply to conduct an if statement using a JavaScript variable, and than edit the swift variable based on that.
Example in code of what I am trying to do:
var checkElement = false
webView.evaluateJavaScript("var element = document.getElementById(\"element\");"){ (value, error) in
if let err = error {
print(err)
}
}
if (element != null){
checkElement = true
}
I understand this won't work due to element only existing in JavaScript. Although, how would I pass the element variable to Swift?