AFNetworking 2: Limiting the Maximum Number of Concurrent Download Tasks

I am dealing with an application that implements a download queue created using AFNetworking 2.0, and I will be interested to know if there is a way to limit the maximum number of download tasks ( NSURLSessionDownloadTask ) running at the same time.

My ultimate goal is that my download queue manages all the tasks, so one of them is completed, then the next one starts.

I know that, for example, NSOperationQueue has a maxConcurrentOperationCount property, but I don't know if AFNetworking 2.0 uses NSOperationQueue at a lower level with load tasks. In addition, I know that AFURLSessionManager has an NSArray with all loading tasks running, but it's just an array.

thanks

+7
ios iphone ios7 afnetworking-2
source share
1 answer

AFNetworking has an operation queue in which you can set the number of concurrent operations

 [[self.requestOperationManager operationQueue] setMaxConcurrentOperationCount:2]; 

This is great for downloads and queries.

Note: a good method that I use is to have 2 network managers, one for regular queries that has setMaxConcurrentOperationCount 1 (I need my queries to execute sequentially) and a bootloader that set MaxConcurrentOperationCount to 2

+13
source share

All Articles