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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With