I want to store the response fetched from a request in NSUrlCache.How
. How can this be done?
-(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];
}
}
Now I am trying to remove the object for request requestImage
and I am trying to do this as follows:
- (IBAction)clearImage:(id)sender {
[Cache removeCachedResponseForRequest:requestImage];
}
But this doesn't work. Why?