Created
September 4, 2014 17:20
-
-
Save sheeley/fc25ab55fc091f3d79ee to your computer and use it in GitHub Desktop.
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
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