I want to login many accounts of same site in different webView
. For example i have Tab Bar Controller
that contains three view controllers
You can do this with WKWebView
by using different instances of WKWebSiteDataStore
:
let configuration1 = WKWebViewConfiguration()
configuration1.websiteDataStore = WKWebsiteDataStore.nonPersistent()
self.webView1 = WKWebView(frame: CGRect.zero, configuration: configuration1)
self.view.addSubview(self.webView1)
let configuration2 = WKWebViewConfiguration()
configuration2.websiteDataStore = WKWebsiteDataStore.nonPersistent()
self.webView2 = WKWebView(frame: CGRect.zero, configuration: configuration2)
Unfortunately, you will loose webView
data (such as cookies, cache, etc) after app restart, because non-persistent WKWebsiteDataStore
can't be saved to disk (you could notice that WKWebsiteDataStore
implements NSCoding
, but it doesn't work for non-persistent stores).