
This video is only available to subscribers. Start a subscription today to get access to this and 469 other videos.
Tracking Download Progress
Episode
#14
|
6 minutes
| published on
May 3, 2012
Subscribers Only
In this episode, we'll use AFNetworking to track the progress of a file download and display it in a UIProgressView. Once we've downloaded a small movie, we'll play it using MPMoviePlayerViewController.
Links
Tracking Progress with AFNetworking
[op setDownloadProgressBlock:^(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
if (totalBytesExpectedToRead > 0) {
dispatch_async(dispatch_get_main_queue(), ^{
self.progressView.alpha = 1;
self.progressView.progress = (float)totalBytesRead / (float)totalBytesExpectedToRead;
NSString *label = [NSString stringWithFormat:@"Downloaded %lld of %lld bytes",
totalBytesRead,
totalBytesExpectedToRead];
self.progressLabel.text = label;
});
}
}];