title: Xcode WKWebView code to allow WebView to process popups
body: <p>I am totally new to Xcode and the syntax is totally escaping me. </p>
  
  <p>I have one thing left to do and then I've achieved what I need to within Xcode.</p>
  
  <p>I need to insert a function that allows the WebView to process popups, but I have no idea where to begin inserting the code. </p>
  
  <p>This is the current code: </p>
  
  <pre><code>import UIKit
  import WebKit
  
  class ViewController: UIViewController, WKNavigationDelegate {
      override func viewDidLoad() {
          super.viewDidLoad()
          let webView = WKWebView()
          let htmlPath = Bundle.main.path(forResource: "index", ofType: "html")
          let folderPath = Bundle.main.bundlePath
          let baseUrl = URL(fileURLWithPath: folderPath, isDirectory: true)
          do {
              let htmlString = try NSString(contentsOfFile: htmlPath!, encoding: String.Encoding.utf8.rawValue)
              webView.loadHTMLString(htmlString as String, baseURL: baseUrl)
          } catch {
              // catch error
          }
          webView.navigationDelegate = self
          view = webView
      }
  }
  </code></pre>
  
  <p>How do I edit this in order to allow popups? </p>
  
  <p>Please remember that I don't know how to add the solutions that I'm finding, so please show me where to insert the snippet as well.</p>