title: WKWebVIew Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
body: <p>I know this question is asked many times over here but I have tried all the solutions but none of them helped me out.</p>
  <p>I am getting error in this line</p>
  <p><code>myWebView.load(URLRequest(url: url))</code></p>
  <p>I am using navigation controller and segue performs programatically when the user defaults are available from below</p>
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
  let defaults = UserDefaults.standard
  var username = &quot;&quot;
  var password = &quot;&quot;
  
  override func viewDidLoad() {
      super.viewDidLoad()
      
      if(defaults.bool(forKey: &quot;isLoggedin&quot;) == true){
          username = defaults.string(forKey: &quot;username&quot;) ?? &quot;&quot;
          password = defaults.string(forKey: &quot;password&quot;) ?? &quot;&quot;
      
          if(username != &quot;&quot; &amp;&amp; password != &quot;&quot;){
              self.navigationController?.pushViewController(WebViewViewController(), animated: true)
          }
      }
  }
  
  }
  </code></pre>
  <p>Following is my webview uiViewController</p>
  <pre><code>import UIKit
  import WebKit
  
  class WebViewViewController: UIViewController {
  @IBOutlet weak var myWebView: WKWebView!
  
  let defaults = UserDefaults.standard
  var username = &quot;&quot;
  var password = &quot;&quot;
  
  override func viewDidLoad() {
      super.viewDidLoad()
      //myWebView = WKWebView()
      
      navigationController?.setNavigationBarHidden(true, animated: true)
      
      if(defaults.bool(forKey: &quot;isLoggedin&quot;) == true){
          username = defaults.string(forKey: &quot;username&quot;) ?? &quot;&quot;
          password = defaults.string(forKey: &quot;password&quot;) ?? &quot;&quot;
      
          if(username != &quot;&quot; &amp;&amp; password != &quot;&quot;){
              guard let url = URL(string: &quot;https://google.com&quot;) else {return}
              myWebView.load(URLRequest(url: url))
          }
      }
      
  }
  }
  </code></pre>
  <p>My story board screen shot<a href="https://i.stack.imgur.com/sYTA6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sYTA6.jpg" alt="enter image description here" /></a></p>