title: How can I clear a WKWebview that is contained in a custom UITableViewCell that is reused?
body: <p>I have a UITableView that dequeues my custom UITableViewCell.  The UITableViewCell contains a WKWebView.  In cellForRowAtIndexPath, I set the url that the WKWebView should load and the webview starts to load the page.  The problem is that the data of the cell, sometimes displays the "old" data while the new url is still loaded.  </p>
  
  <p>I tried to first load about:blank and I also tried <code>webView.loadHTMLString("", baseURL: nil)</code>, but it did not work, because it is an async operation.  </p>
  
  <p>Here is pieces of my code.</p>
  
  <pre><code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: MyTableViewController.cellIdentifier, for: indexPath) as! MyTableViewCell
      cell.url = data[(indexPath as NSIndexPath).row]
      return cell
  }
  </code></pre>
  
  <p>In MyTableViewCell, I immediately start to load the html.  loadHTML(in:,forUrl:) is a private function that loads the url into the webview.</p>
  
  <pre><code>var url: String? {
      didSet {
          loadHTML(in:webView!, forURL:url)
      }
  }
  </code></pre>
  
  <p>It will be much appreciated if someone knows how to do this properly.  Some suggestions that I have seen included, hiding the webView until it is finished loaded.  I would actually like my user to see the progress in loading.  </p>
  
  <p>I don't think it would be a good idea not to dequeue the UITableViewCell.  (The cell contain other controls too.)  The best I can think of right now, is to remove the WKWebView and adding it again.</p>