title: Swift : WKWebView : Fatal error: Unexpectedly found nil while unwrapping an Optional value
body: <p>I'm trying to add subview to mainView but sometime is working sometime got error. I don't know why like that. </p>
  
  <p>What's wrong ? Thank.</p>
  
  <pre><code>func setURL(url_string : String){
      DispatchQueue.main.async {
          self.webView = WKWebView(frame : CGRect(x: 0.0, y: 0.0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
  
          if let url = URL(string: url_string) {
              self.webView?.navigationDelegate = self
              if let web = self.webView {
                  self.mainView.addSubview(web) // got Error Here
              }
              self.webView?.load(URLRequest(url: url))
          }
      }
  }
  
  func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
      self.loadingIndicator.stopAnimating()
      self.loadingIndicator.isHidden = true
  }
  </code></pre>