Search code examples
iphoneiosobjective-cnsoperationnsoperationqueue

How to use NSOperationQueue to download audio files from server one by one


I have an array containing audio file url's. I want to fetch audio files from server using these url's in background mode. I have heard that i can achieve this with NSOperationQueue. My query is

1)How can i achieve this.

2)How can i get call back on single operation completion/failure

3)How can i get call back after completion of the whole process.

I need these call backs to keep track of downlaod process so that i can update my database about the download status of files. So, in case any internet connection loss i can download the remaning files again.

Any idea will be helpful as i am new to NSOperationQueue.


Solution

  • Seems like AFNetworking has all that you need (callback blocks for success / failure, puttings requests in NSOperationQueue). In your case probably AFHttpClient and its enqueueHTTPRequestOperation method will do the job.