Set number of concurrent downloads with NSURLSessionDownloadTask

Cory Imdieke picture Cory Imdieke · Jan 2, 2014 · Viewed 17.6k times · Source

I'm using the new NSURLSession API and allowing the user to download files. I'd like to try and tell my NSURLSession how many simultaneous downloads to run, but I don't see a way to do it. I'd like to try to avoid managing the download tasks myself, would be much better if I could tell the system how many to allow instead - that would be better for queuing background downloads as well when my app isn't running. Is there a way to do this?

Answer

CouchDeveloper picture CouchDeveloper · Jan 2, 2014

You can set it in the NSURLSessionConfiguration object with the HTTPMaximumConnectionsPerHost property.