iOS UIWebView清除缓存

UIWebView清除Cookie:

复制代码
//清除cookies
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) 
{
    [storage deleteCookie:cookie];
}
复制代码

UIWebView清除缓存:

//清除UIWebView的缓存
[[NSURLCache sharedURLCache] removeAllCachedResponses];

//清除缓存(全)
NSURLCache * cache = [NSURLCache sharedURLCache];  
[cache removeAllCachedResponses];  
[cache setDiskCapacity:0];  
[cache setMemoryCapacity:0];
posted @ 2014-10-27 16:44  韦韦韦  阅读(593)  评论(0编辑  收藏  举报