このダウンロード画像を使用
または、AFNetworking ライブラリリンクを使用して画像をダウンロードします。ライブラリをダウンロードし、AFNetworking フォルダーをプロジェクトに追加します。必要なフレームワーク (Security、MobileCoreServices、および SystemConfiguration) を追加し、AFImageRequestOperation クラスを使用します。
このコードを使用して画像をダウンロードします
-(void)downloadImage:(NSString *)imageUrl {
// download the photo
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:imageUrl]];
AFImageRequestOperation *operation = [AFImageRequestOperation
imageRequestOperationWithRequest:request
imageProcessingBlock:nil
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image)
{
if (image != nil) {
NSLog(@"image downloaded %@", image);
[self.imageArray addObject:image];
}
//put code to add image to image view here
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
NSLog(@" error %@", error.description);
}];
[operation start];
}