UIWebview without Cache

前端 未结 4 845
旧巷少年郎
旧巷少年郎 2020-12-05 05:04

I want to load a webview without cache?

//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Request Object
NSURLRequest *requestObj =         


        
4条回答
  •  误落风尘
    2020-12-05 05:45

    Objective-C:

    // Remove and disable all URL Cache, but doesn't seem to affect the memory
    [[NSURLCache sharedURLCache] removeAllCachedResponses];
    [[NSURLCache sharedURLCache] setDiskCapacity:0];
    [[NSURLCache sharedURLCache] setMemoryCapacity:0];
    

    You can find more information in http://blog.techno-barje.fr/post/2010/10/04/UIWebView-secrets-part2-leaks-on-release/

    Swift:

    URLCache.shared.removeAllCachedResponses()
    URLCache.shared.diskCapacity = 0
    URLCache.shared.memoryCapacity = 0
    

提交回复
热议问题