title: download multiple images in iOS App
body: <p>I want to download multiple images from URL to my device in iOS App.</p>
  
  <pre><code>//
  //  ImageDownload.m
  //
  
  #import "ImageDownload.h"
  
  @implementation ImageDownload {
      int *position;
      NSArray *downloableImages;
  }
  
  - (void)start:(NSArray *)images delegate:(id)delegate
  {
      position = 0;
      downloableImages = images;
  
      NSUInteger *count = ((NSUInteger *)[downloableImages count]);
      NSLog(@"%d", count);
  
      [self startDownload];
  }
  
  - (void)startDownload
  {
      NSUInteger *imageDataCount;
  
      NSArray *image;
      NSString *filename;
      NSString *fileurl;
  
      NSURLRequest *imageUrlRequest;
  
      image = [downloableImages objectAtIndex:position];
  
      NSLog(@"%d", position);
  
      NSArray *imageData = [image valueForKey:@"image"];
      imageDataCount = ((NSUInteger *)[imageData count]);
  
      if (imageDataCount &gt; 0) {
          filename = [imageData objectAtIndex:0];
          fileurl = [imageData objectAtIndex:1];
  
          NSLog(@"%@", fileurl);
  
          imageUrlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:fileurl]];
          NSURLConnection *imageUrlConnection = [[NSURLConnection alloc] initWithRequest:imageUrlRequest delegate:self startImmediately:TRUE];
      } else {
          NSUInteger *count = ((NSUInteger *)[downloableImages count]);
  
          if (((NSUInteger *)position) &lt; ((NSUInteger *)count - 1)) {
              position = position + 1;
  
              [self startDownload];
          }
      }
  }
  
  - (void)connectionDidFinishLoading:(NSURLConnection *)connection
  {
      NSLog(@"finish image...");
      NSUInteger *count = ((NSUInteger *)[downloableImages count]);
  
      if (((NSUInteger *)position) &lt; ((NSUInteger *)count - 1)) {
          position = position + 1;
  
          [self startDownload];
      }
  }
  
  @end
  </code></pre>
  
  <p>For now... I only check the position of the download and current URL,
  Exists 27 files to download... but the download not go one by one... check this output:</p>
  
  <blockquote>
    <p>Position: 0<br>
    http.....fichero00.jpg<br>
    Finish download  </p>
    
    <p>Position: 4<br>
    http.....fichero04.jpg<br>
    Finish download  </p>
    
    <p>Position: 8<br>
    http.....fichero08.jpg<br>
    Finish download  </p>
  </blockquote>