#!/usr/blin/perl
while(true) {
++$i--;
}
Friday, June 27, 2014
How to redirect JavaScript console.log() to Xcode's debug output
On iOS >= 7.0 it is pretty easy thanks to brilliant (and undocumented as well) framework:
@import JavaScriptCore;
...
// get UIWebView's JavaScript context
JSContext *ctx = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
// 'listen' to console.log()
ctx[@"console"][@"log"] = ^(NSString *message) {
NSLog(@"Javascript's console.log() :\n%@\n\n", message);
};
Friday, June 13, 2014
Subscribe to:
Comments (Atom)