views:

18

answers:

0

Hi, I'm trying to load a random UIImage from the web using this method

NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] 
                                      initWithTarget:self
                                                 selector:@selector(loadImage) 
                                                    object:nil];
[queue addOperation:operation]; 
[operation release];

- (void)loadImage {
  NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"imageurl.jpg"]];
  UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease];
  [imageData release];
  [self performSelectorOnMainThread:@selector(displayImage:) withObject:image waitUntilDone:NO];
}

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

How would I go about loding an image that is labeled image 1.jpg image 2.jpg and so on. Any Ideas? Thanks