Original posted Address: http://blog.csdn.net/jinglijun/article/details/9048959
To clear all cookie methods:
[HTML] View plain copy nsurl *url = [nsurl urlwithstring:@ "http://www.baidu.com"]; if (URL) { nsarray *cookies = [[nshttpcookiestorage sharedhttpcookiestorage] cookiesforurl:url]; for (int i = 0; i < [cookies count]; i++) { NSHTTPCookie *cookie = (nshttpcookie *) [Cookies objectatindex :i]; [[nshttpcookiestorage sharedHTTPCookieStorage] deleteCookie:cookie]; }
to clear a particular cookie method: [HTML] view plain copy nsarray * cookarray = [[Nshttpcookiestorage sharedhttpcookiestorage] Cookiesforurl:[nsur L URLWithString:self.loadURL]]; NSString * Successcode = @ ""; For (Nshttpcookie*cookie in Cookarray) {if ([Cookie.name isequaltostring:@ "CookieName"]) {[[Nshttpcookiestorage Sharedhttpcookiestorage] Deletecookie:cookie]; } }
to clear a URL cache method:
[HTML] view plain copy [[Nsurlcache Sharedurlcache] Removecachedresponseforrequest:[nsurlrequest Requestwithurl:url]];
Clear All caching methods:
[HTML] View plain copy [[nsurlcache sharedurlcache] removeallcachedresponses];