What's the best way to implement a download queue in iPhone? Can this be done with the ASIHTTPRequest library?
I think it is not difficult to implement one. Here is my strategy:
1/ You have an array of tasks (to be simple, just an array of urls) to store the list of download urls
2/ You can have a singleton object that Whenever, you put url into the queue, you inform it.
3/ When the singleton object is informed, it checks if it is free to do the job. If it is, it takes the first url out of the queue, call asynchronous request to the server. It set its state to be busy.
4/ When the asynchronous request call back, the singleton checks the queue again to see if it is empty. If it is not, then get the next url, do the step 3 again. If it is empty, then the singleton object set its state to be free, then the next object put something into the download queue can inform the singleton object.
You can have many asynchronous request at the time by checking against a constant number. And yes, you can call asynchronous request with ASIHTTPRequest library.
I don't know if there is any library do this job for you, but I think it is easy to implement.
ASIHTTPRequest includes the ASINetworkQueue object with can be used as a download queue, see:
http://allseeing-i.com/ASIHTTPRequest/How-to-use#about_ASINetworkQueues
You can then track overall process like so:
http://allseeing-i.com/ASIHTTPRequest/How-to-use#tracking_download_progress_for_a_set_of_requests