As UIWebView is based on the URL Loading System it will interact which NSURLCache. You can subclass NSURLCache and overwrite Code:- (NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)requestThe cache will get checked for any ressource as long as the cache policy allows it (should be the case per default). So you can check the request-url and return a "faked" response object (which returns data from your bundle).Never checked by assuming this should work.
就不会被autorelease pool收掉
静态配置会加入autorelease pool
下载图片可以段代码
-(NData *)downloadHTTPFile:(NSString *) fileUrl{
return [NSData dataWithContentsOfURL:[NSURL URLWithString:fileUrl]];
}
把UIWebView中的图片url取出,然后再下载
我问的时候说的不明白,我现在直接给你说我的目的。
我做的程序是要显示一个固定网址,这个网址数据会经常更新,但如果用户当前没有联网,那就显示之前的。
所以我想通过控制缓存来做到,但现在觉得可行性不高。
想请问有没有好的办法?关于问题2,
我看了下API说明,有一点想确认一下。
是不是默认先从本地缓存取得?因为我要取得图片都比较大,二次下载是绝对不可以的。以上。
您可以自行创建,将整个保存下来,只是很麻烦
如果有的话,基本上应该是都不用管,您的问题就解决了...另外google了一下,看起来是有的.....
Code:- (NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)requestThe cache will get checked for any ressource as long as the cache policy allows it (should be the case per default). So you can check the request-url and return a "faked" response object (which returns data from your bundle).Never checked by assuming this should work.