//Global variables
//
//Note: using anything else than non-persistent will not work
////////////////////////////////////////////////////////////////////////////////
let websiteDataStoreA = WKWebsiteDataStore.nonPersistent()
let websiteDataStoreB = WKWebsiteDataStore.nonPersistent()
let processPoolA = WKProcessPool() //May not be needed
let processPoolB = WKProcessPool() //May not be needed
let useWebsiteDataStoreA = true
//Extend WKWebView : Maybe there is another way, but I have read that
// websiteDataStore must be selected in the init() and
// not after.
////////////////////////////////////////////////////////////////////////////////
class myWeb: WKWebview {
init() {
let configuration = WKWebViewConfiguration()
//Choose your cookie jar (and many other things)
////////////////////////////////////////////////
if useWebsiteDataStoreA {
configuration.websiteDataStore = websiteDataStoreA
configuration.processPool = processPoolA //May not be needed
}
else {
configuration.websiteDataStore = websiteDataStoreB
configuration.processPool = processPoolB //May not be needed
}
super.init(frame: CGRect(x: 0, y: 0, width: 512, height: 512),
configuration: configuration)
}
}