title: Download images in order with AFNetworking
body: <p>How do you download images in order with AFNetworking? An by "in order", I also mean executing the <code>success</code> blocks in order.</p>
  
  <p>Initially I thought it would be enough to use a <code>NSOperationQueue</code> and set each <code>AFImageRequestOperation</code> as a dependency of the next one. Like this:</p>
  
  <pre><code>- (void) downloadImages
  {
      { // Reset
          [_downloadQueue cancelAllOperations];
          _downloadQueue = [[NSOperationQueue alloc] init];
          _images = [NSMutableArray array];
      }
      AFImageRequestOperation *previousOperation = nil;
      for (NSInteger i = 0; i &lt; _imageURLs.count; i++) {
          NSURL *URL = [_imageURLs objectAtIndex:i];
          NSURLRequest *request = [NSURLRequest requestWithURL:URL];
          AFImageRequestOperation *operation = [AFImageRequestOperation 
                                                imageRequestOperationWithRequest:request 
                                                imageProcessingBlock:nil 
          success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
              [_images addObject:image];
              NSLog(@"%d", i);
          } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {}];
  
          if (previousOperation) {
              [operation addDependency:previousOperation];
          }
          previousOperation = operation;
  
          [_downloadQueue addOperation:operation];
      }
  }
  </code></pre>
  
  <p>This prints <code>i</code> in order when the images are downloaded. However, when the requests are already cached, the success blocks are processed out of order. I suspect this is a <code>NSOperation</code> limitation, not AFNetworking.</p>
  
  <p>Am I missing something?</p>