Search code examples
ios7nsurlsessionnsurlsessionconfiguration

Multiple background downloads in ios7 using NSURLSessionConfigurations


I want to know about how to download a bunch of files one after the other. It is like if I have 5 files to download, I should automatically download all the 5 files in a sequence 1 complete then 2 , 2 then 3 this way all five should be completed automatically. Its should all done in the background of my app . Thanks in advance


Solution

  • You should use NSURLSession. You can create a background session which will even continue to work after your app goes to the background and/or is terminated.

    You ask the associated NSURLSessionTasks to download all the files, and the framework will take care of downloading as many of the files concurrently as makes sense (given the bandwidth etc.).

    You'll be able to get download status if you need, and will get notified to completion of the downloads, even if your app wasn't running anymore. There's a lot to love about NSURLSession. You should consider it for all long running download/upload tasks.