title: How to fix "EXC_BAD_ACCESS" when creating WKPreferences variable in Swift 4
body: <p>In my code, I have a part that creates a new <code>WKWebView</code> with a specific <code>WKWebViewConfiguration</code>, which in turn has a <code>WKPreferences</code> reference. All of this then gets added to the view of the application. </p>
  
  <p>The problem is that up until this point, my code has been running perfectly, with no problems. </p>
  
  <p>Now, for some bizarre reason, when I launch the application, 
  I get </p>
  
  <blockquote>
    <p>Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffeec686fc0)</p>
  </blockquote>
  
  <p>on the line when I create a variable for the <code>WKPreferences</code>.</p>
  
  <p>I am working with <code>Xcode 10.1</code>, <code>Swift 4</code>, and I have <code>Alamofire</code> and <code>NetworkReachability</code> pods installed. I have tried just creating the <code>WKWebView</code> without the <code>WKPreferences</code>, but the error just moves on to the <code>WKWebViewConfiguration</code> instead.</p>
  
  <pre><code>func createWebView() {
      let preferences = WKPreferences()   //&lt;-- EXC_BAD_ACCESS
      preferences.javaScriptEnabled = true
      let webConfiguration = WKWebViewConfiguration()
      webConfiguration.preferences = preferences
      webConfiguration.allowsInlineMediaPlayback = true
      webViewVar = WKWebView(frame: self.view.bounds, configuration: webConfiguration)
      webViewVar.uiDelegate = self
      self.view = webViewVar
  }
  
  override func loadView() {
      createWebView()
  }
  </code></pre>
  
  <p>The expected behavior is that the app would launch and show a web page, that doesn't change, specified elsewhere in the code. The actual result is that the app crashes with the <code>EXC_BAD_ACCESS</code> error upon startup.</p>