AFNetworking 2: Limit max number of concurrent Download Tasks
afnetworking-2, ios, ios7, iphone
Solution
AFNetworking has an operation queue, which you can set the number of concurrent operations
[[self.requestOperationManager operationQueue] setMaxConcurrentOperationCount:2];
this works fine for downloads and requests
Note: a good technique that i use, is to have 2 network managers, one for common requests, which has setMaxConcurrentOperationCount of 1 (i need my requests to be performed sequentially) and a downloader, which has setMaxConcurrentOperationCount to 2
Problem
I'm dealing with an app that implements a download queue created with AFNetworking 2.0 and I will like to know if there is a way to limit the maximum number of download tasks (`NSURLSessionDownloadTask`) running at the same time. My final goal is that my download queue manages all the tasks so one is finished, then the next one will start. I know that, for example, `NSOperationQueue` has the `maxConcurrentOperationCount` property, but I don't know if AFNetworking 2.0 uses NSOperationQueue in a lower level with download tasks. Also, I know that `AFURLSessionManager` has an `NSArray` with all the running download tasks, but is just that, an array. Thanks