         var delegate: WebViewControllerNavigationDelegate?
 
         func userContentController(userContentController: WKUserContentController, didReceiveScriptMessage message: WKScriptMessage) {
-            if let body = message.body as? [String: AnyObject] {
-                var name = body["name"] as? String
-                var data = body["data"] as? String
-
-                switch name! {
-                case "visitLocation":
-                    self.delegate?.visitLocation(NSURL(string: data!))
-                case "locationChanged":
-                    self.delegate?.locationDidChange(NSURL(string: data!))
-                default:
-                    println("Unhandled message: \(name): \(data)")
-                }
+            if let body = message.body as? [String: AnyObject],
+                name = body["name"] as? String,
+                data = body["data"] as? String {
+                    switch name {
+                    case "visitLocation":
+                        if let location = NSURL(string: data) {
+                            self.delegate?.visitLocation(location)
+                        }
+                    case "locationChanged":
+                        if let location = NSURL(string: data) {
+                            self.delegate?.locationDidChange(location)
+                        }
+                    default:
+                        println("Unhandled message: \(name): \(data)")
+                    }
             }
         }
     }
 
-    var URL = NSURL(string: "http://turbolinks.dev/")
+    var URL = NSURL(string: "http://turbolinks.dev/")!
     var activeSessionTask: NSURLSessionTask?
 
     static let sharedWebView: WKWebView = {

import WebKit

protocol WebViewControllerNavigationDelegate {
    func visitLocation(URL: NSURL!)
    func locationDidChange(URL: NSURL!)
}

class WebViewController: UIViewController, WebViewControllerNavigationDelegate {

    
    // MARK - WebViewControllerNavigationDelegate

    func visitLocation(location: NSURL) {
        let request = NSURLRequest(URL: location)
        loadRequest(request)
    }
    
    func locationDidChange(location: NSURL) {
        
    }
}

func JSONStringify(object: AnyObject) -> NSString {
    if let data = NSJSONSerialization.dataWithJSONObject([object], options: nil, error: nil),
        string = NSString(data: data, encoding: NSUTF8StringEncoding) {
            return string.substringWithRange(NSRange(location: 1, length: string.length - 2))
    } else {
        return "null"
    }
