title: Clear WebView cache xamarin IOS
body: <p>I need to clear cache after closing WebView
  I use code from <a href="https://stackoverflow.com/questions/36989788/xamarin-ios-clear-cache-from-wkwebview">Xamarin iOS clear cache from WKWebView</a>
  But it has no effect. Already understand that <code>records.Count equals 0</code> </p>
  
  <p>How to make it right?</p>
  
  <pre><code>var websiteDataTypes = new NSSet&lt;NSString&gt;(new []
  {
      //Choose which ones you want to remove
      WKWebsiteDataType.Cookies,
      WKWebsiteDataType.DiskCache,
      WKWebsiteDataType.IndexedDBDatabases,
      WKWebsiteDataType.LocalStorage,
      WKWebsiteDataType.MemoryCache,
      WKWebsiteDataType.OfflineWebApplicationCache,
      WKWebsiteDataType.SessionStorage,
      WKWebsiteDataType.WebSQLDatabases
  });
  
  WKWebsiteDataStore.DefaultDataStore.FetchDataRecordsOfTypes (websiteDataTypes, (NSArray records) =&gt;
  {
      for (nuint i = 0; i &lt; records.Count; i++) {
          var record = records.GetItem&lt;WKWebsiteDataRecord&gt; (i);
  
          WKWebsiteDataStore.DefaultDataStore.RemoveDataOfTypes (record.DataTypes, 
              new[] {record}, () =&gt; {Console.Write($"deleted: {record.DisplayName}");});
      }
  });
  </code></pre>