Created
June 14, 2018 19:24
-
-
Save deckerego/53fd6f12c27dea310be3c845a0872d4f to your computer and use it in GitHub Desktop.
Example of executing JavaScript in iOS using Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let context = JSContext()! | |
let myNumber = 12 | |
context.setObject(myNumber, forKeyedSubscript: "myNumber" as NSString) | |
let result = context.evaluateScript("myNumber + 20;") | |
print("JavaScript eval: \(result!.toInt32())") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment