iOS 清除UIWebView缓存

清除webview cookies&缓存

//清除cookies

1
2
3
4
5
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]){
[storage deleteCookie:cookie];
}

// 清除webView的缓存

1
2
3
4
5
6
7
- (void)cleanCache{
//清除UIWebView的缓存
NSURLCache *cache = [NSURLCache sharedURLCache];
[cache removeAllCachedResponses];
[cache setDiskCapacity:0];
[cache setMemoryCapacity:0];
}
招摇撞骗