Skip to content

Instantly share code, notes, and snippets.

@ostholz
Created June 21, 2013 14:34
Show Gist options
  • Save ostholz/5831587 to your computer and use it in GitHub Desktop.
Save ostholz/5831587 to your computer and use it in GitHub Desktop.
AFNetwork download Progress
[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;
});
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment