         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 {


    private func loadRequest() {
        if webView.URL == nil {
            let request = NSURLRequest(URL: URL)
            webView.loadRequest(request)
        }
    }
