"2.pd...">

How to clear cache in UIWebView in swift?

I use tableview to display different PDF files locally. For instance:

pdf1 -> "1.pdf"
pdf2 -> "2.pdf"
pdf3 -> "3.pdf"

There is no problem in my first click, but when I click again, it loads another pdf file. Example: I use pdf2, but download pdf1.

Can you help me in this matter, I'm new to quick ...

+4
source share
1 answer

You can easily do this with

NSURLCache.sharedURLCache().removeAllCachedResponses()
NSURLCache.sharedURLCache().diskCapacity = 0
NSURLCache.sharedURLCache().memoryCapacity = 0

Also use this:

let url = NSURL(string: "http://www.web.com")
let url_request = NSURLRequest(URL: url,
    cachePolicy: NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData,
    timeoutInterval: 5.0)

let webView = UIWebView()
webView.loadRequest(url_request)

thank

0
source

Source: https://habr.com/ru/post/1651979/


All Articles