title: How to asynchronously download 1000 images?
body: <p>I downloaded around 1000 images from URLs to the iPhone file system, but I'd like to do it asynchronously. Currently I'm using this code:</p>
  
  <pre><code>-(void)saveImageInFile:(NSString *)imageName image:(UIImage *)img{
  
      // add the images in the file
      NSData *tmpData;
  
      if ([self.constImageType isEqualToString:@"png"]) {
          tmpData = UIImagePNGRepresentation (img);
      }
  
      else if ([self.constImageType isEqualToString:@"jpg"]) {
          tmpData = UIImageJPEGRepresentation(img, 0.7f);
      }
  
      NSString *path = [self.documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", imageName,self.constImageType]];
      //NSLog(path);
      [tmpData writeToFile:path atomically:YES];
  
  }
  </code></pre>