Created
July 9, 2017 09:08
-
-
Save szastupov/3d18e37865974cc4f9fd74fdcff3f88e to your computer and use it in GitHub Desktop.
console.log() for jscore in 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
context.evaluateScript("var console = { log: function(...args) { _consoleLog(args.join(' ')) } }") | |
let consoleLog: @convention(block) (String) -> Void = { message in | |
print("console.log: " + message) | |
} | |
context.setObject(unsafeBitCast(consoleLog, to: AnyObject.self), forKeyedSubscript: "_consoleLog" as (NSCopying & NSObjectProtocol)!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment