I want to both download, save, and display an image.
I am using this code, which DOES work when I directly load *image.
[self.imageView setImageWithURLRequest:request placeholderImage:nil
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
// Set the image
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Image.png"];
// Save image.
[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES];
UIImage * imag2e = [UIImage imageNamed: @"Image"];
weakSelf.imageView.image = imag2e;
[self updateZoom];
[self updateConstraints];
[MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"An error occured when loading the image, %@", [error description]);
[MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
}];