how to download multiple images asynchronously


Possible Duplicate:
Download image asynchronously

I would like to download multiple images asynchronously. I have array of 10 images and I want to show these images in 10 uiimageview, I am doing like this but it show only one image

- (void)loadImage {
  NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[myarray objectatindex:0]]];
  UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease];
  [imageData release];
  [self performSelectorOnMainThread:@selector(displayImage:) withObject:image waitUntilDone:NO];

The final method we need to create takes in the image to display and sets it on our image view.

- (void)displayImage:(UIImage *)image {
  [imageView setImage:image]; //UIImageView

So kindly tell me how I can show multiple images on different without creating 10 different methods.

Don't use the initWithContentsOfURL method of NSData, which is synchronous.

You may want to consider the UIImageView+AFNetworking category that you can find here, that adds to UIImageView the ability to retrieve its content asynchronously.

As suggested in the comments you can also look at SDWebImage, which does basically the same.