Skip to content

Instantly share code, notes, and snippets.

@sheeley
Created September 4, 2014 17:20
Show Gist options
  • Save sheeley/fc25ab55fc091f3d79ee to your computer and use it in GitHub Desktop.
Save sheeley/fc25ab55fc091f3d79ee to your computer and use it in GitHub Desktop.
class FRWindowController {
// ...
// here we can log both output and command together
func runJavaScript(command: String){
webView?.evaluateJavaScript(command, completionHandler: { (output, error) -> Void in
// woo hoo
NSLog("\(command) has output \(output)")
})
}
// if i want to pass this in, so we could do something like
// func runJavaScript(command : String, completionHandler: ((AnyObject!, NSError!) -> Void))
// how do we access command?
func defaultCompletionHandler(output: AnyObject!, error: NSError!) -> Void {
if(error != nil){
FRLogger.sharedInstance.error("Error running js command:'\(command)', error:'\(error)'")
}
if(output != nil){
FRLogger.sharedInstance.info("Output from command: '\(command)', output:'\(output)'")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment