Susitha
Susitha

Reputation: 3349

Show progress for downloading image using AFNetworkig

I wanted to show progress when downloading a large image. I am setting the image path as follows.

UIImage *backgroundImage =[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:backgoundImagePath]]];

How can i show the download progress of the image using AFNetworking framework.

Upvotes: 0

Views: 67

Answers (1)

Hiren Varu
Hiren Varu

Reputation: 1477

try this one,

[manager setDownloadTaskDidWriteDataBlock:^(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
float percentageDone = ((float)totalBytesWritten/(float)totalBytesExpectedToWrite)*100;
      NSLog(@"Downloading..%.f",percentageDone);   
}];

Upvotes: 1

Related Questions