Created
December 7, 2014 22:37
-
-
Save pietrorea/8309d74336bd82c127ae to your computer and use it in GitHub Desktop.
Cast Swift closure as Objective-C block (needed for JavaScriptCore)
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
var block : @objc_block (NSString!) -> Void = { | |
[unowned self] (string : NSString!) -> Void in | |
let jsText = "\(string)\n" | |
self.outputTextView.setText(jsText, concatenate: true) | |
} | |
context.setObject(unsafeBitCast(block, AnyObject.self), | |
forKeyedSubscript: "print") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment