我想在NSUrlCache.How
中存储从请求中获取的响应。怎么办呢?
-(void)sendRequestForImage
{
NSCachedURLResponse * cachedResponse = [Cache cachedResponseForRequest:requestImage];
if(!cachedResponse.data)
{
NSString*imageStr=[NetworkManger getImage:requestImage];
_imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageStr]]];
}
else
{
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:cachedResponse.data options:NSJSONReadingAllowFragments error:nil];
}
}
现在我正在尝试删除请求requestImage
的对象,我尝试按以下方式执行此操作:
- (IBAction)clearImage:(id)sender {
[Cache removeCachedResponseForRequest:requestImage];
}
但这不起作用。为什么呢?