I'm trying to add UIImage objects into an array but they are not being added. Please help
my code:
imageArray = [[NSMutableArray alloc] init];
arry = [[NSMutableArray alloc] init];
[arry addObject:@"http://adjingo.2cimple.com/content/151/Image/6291.jpg"];
[arry addObject:@"http://adjingo.2cimple.com/content/151/Image/6290.jpg"];
//Fetch images from web and store in another array
for (int i=0; i<[arry count]; i++)
{
NSString *string=[arry objectAtIndex:i];
NSURL *url=[NSURL URLWithString:string];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if ( !error )
{
UIImage *image = [[UIImage alloc] initWithData:data];
//Store image in imageArray
[imageArray insertObject:image atIndex:i];
} else{
}
}];
}
NSLog(@"%lu",(unsigned long)[imageArray count]); //this line is always showing 0 as count
When I'm printing the count of the array containing UIImage objects, its showing 0.
(I actually want to download images at once in array, then show it un UIImageView as slideshow).
Please guide me. Thank you!
NSDataobjects. 2. There is no problem with saving theNSImageobjects in anNSMutableArray, it is only the pointers that are in the array.