In my code, I am downloading all of the images in the beginning of the application lifecycle:
[ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]];
NSURL *url = [NSURL URLWithString:[item imagePath]];
__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setCompletionBlock:^{
//NSData *responseData = [request responseData];
//[iw setImage: [UIImage imageWithData:responseData] forState:UIControlStateNormal];
}];
[request setFailedBlock:^{
// NSError *error = [request error];
//[iw setImage:nil forState:UIControlStateNormal];
}];
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[request startSynchronous];
}];
All of the image names are unique. And they are not changing frequently. What I need is, keeping the image in the cache also after application finishes. And when I open the application again, it reads it from the downloaded cache.
Is it possible?