Anon
Anon

Reputation: 623

single ProgressView for multiple file(s) download task

I am Not Using: ASIHTTPRequest, AFNetworking, RestKit.

I have multiple images/files to be downloaded via Asynchronous call to web service for downloading.

I am showing SVProgressHUD (Activity Indicator, NOT Bar) during the download process.

Till this point, everything works fine.

Now, my client wants me to show the single ProgressBar on the view for file(s) being downloaded, so as to make user aware about the approximate time it would take.

Problem: How can I get consolidated time/size for the files being downloaded Asynchronously.

I am open for using any API that serves the purpose. I hope I am making sense, here.

Hard Time. Any Hints?

Upvotes: 2

Views: 908

Answers (2)

Camsoft
Camsoft

Reputation: 12005

Take a look at NSProgress, it's not a UIKit class but will allow you to crate multiple instances of NSProgress (one for each activity) and then get a combined progress value which you can hook up to your UI.

There a good write up about it here with examples: http://oleb.net/blog/2014/03/nsprogress/

You basically use KVO to read the progress value and then update your UI element i.e. progress bar.

Upvotes: 3

Konstantin Brodin
Konstantin Brodin

Reputation: 142

One option is to get length of all files with "head" request, then just calculate it yourself: amount of data downloaded/total-data-length.

This post will help you to get total content length: Objective-c Check file size from URL without downloading

Other option - start downloading each file in separate thread and use shared variable to get consolidated time.

Hope this helps.

Upvotes: 1

Related Questions