Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would consider using an <code>AFHTTPClient</code> to handle your downloads especially since you want to manage multiple downloads. Once you initialise the client, you would need to create all your operations and then add them to the clients operation queue using the method <code>-[AFHTTPClient enqueueBatchOfHTTPRequestOperations: progressBlock: completionBlock:]</code> This way you can also determine the progress of the download using the progress block. Furthermore, the completion block will allow you to perform your own custom code on completion.</p> <p>So you would start by initialising your client:</p> <pre><code>AFHTTPClient *client =[AFHTTPClient clientWithBaseURL:baseURL]; </code></pre> <p>Then you want to create your HTTP Request Operations:</p> <pre><code>NSMutableURLRequest *request = [client requestWithMethod:@"GET" path:@"/" parameters:nil]; AFHTTPRequestOperation *firstOperation = [client HTTPRequestOperationWithRequest:request success:nil failure:nil]; AFHTTPRequestOperation *secondOperation = [client HTTPRequestOperationWithRequest:request success:nil failure:nil]; </code></pre> <p>Then you would simply add these operations to the clients operation queue:</p> <pre><code>[client enqueueBatchOfHTTPRequestOperations:@[firstOperation, secondOperation, thirdImageRequestOperation] progressBlock:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) { //Handle progress here } completionBlock:^(NSArray *operations) { //Handle completion of all downloads here }]; </code></pre> <p>Hope this helps:)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload