Web サーバーから写真アプリに直接進行中の画像を保存しようとしています。これは私が現在進歩なしで使用しているものです:
NSURLSessionDownloadTask *dl = [[NSURLSession sharedSession]
downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
if ( !error )
{
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:location]];
completionBlock(YES,image);
} else{
completionBlock(NO,nil);
}
}
];
[dl resume];
を使用してダウンロードの進行状況を取得できることはわかっていますが、イメージのダウンロードNSURLSessionDownloadDelegate
に使用して、ダウンロード中に進行状況を取得したいと考えています。AFNetworking
AFNetworkingには、次のようなイメージビューで画像を表示する方法があることを知っています
[postCell.iv_postImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[[Utilities sharedUtilities] basePath],[item.imagePath substringFromIndex:2]]]];
しかし、画像をダウンロードするだけの方法はありますか?