Swift 3 Optional trouble. Can't unwrap url with passed in string
<p>I am passing in a string variable to open a url in a webview and when I create the url based on the string its not unwrapping. I'm not sure what I'm doing wrong. Here is the code:</p>

<pre><code>class WebViewController: UIViewController, WKUIDelegate {

var urlString:String?
var vehicle:Vehicle?
var theUrlString = "http://www.ksl.com/auto/search/" //This variable is set in the prepareForSegue in a previous view controller. It is set correctly

var webView: WKWebView!


override func loadView() {
    let webConfiguration = WKWebViewConfiguration()
    webView = WKWebView(frame: .zero, configuration: webConfiguration)
    webView.uiDelegate = self
    view = webView
    if let urlStri = urlString {
        print("url is " + urlStri)
        theUrlString = urlStri
    }else {

    }

}

override func viewDidLoad() {
    super.viewDidLoad()

    print("theUrlString is " + theUrlString) // this correctly prints: theUrlString is http://www.ksl.com/auto/search/index?keyword=&amp;make%5B%5D=Chevrolet&amp;model%5B%5D=Silverado 1500&amp;yearFrom=2006&amp;yearTo=2008&amp;mileageFrom=&amp;mileageTo=&amp;priceFrom=&amp;priceTo=&amp;zip=&amp;miles=25&amp;newUsed%5B%5D=All&amp;sellerType%5B%5D=&amp;postedTime%5B%5D=&amp;titleType%5B%5D=&amp;body%5B%5D=&amp;transmission%5B%5D=&amp;cylinders%5B%5D=&amp;liters%5B%5D=&amp;fuel%5B%5D=&amp;drive%5B%5D=&amp;numberDoors%5B%5D=&amp;exteriorCondition%5B%5D=&amp;interiorCondition%5B%5D=&amp;cx_navSource=hp_search
    if let url = URL(string: theUrlString){

        let myRequest = URLRequest(url: url) //In debugging, it never makes it inside the if statement here

        webView.load(myRequest)
    }


}
</code></pre>