views:

145

answers:

2

Hi i am retrieving image to my second view using URL,problem is i cannot able to assign the image to the UIImageView object

this code working fine

NSData imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://dblog.com.au/wp-content/galah.jpg"]];
UIImage animalImage = [[UIImage alloc] initWithData:imageData];

problem in this code

  1. [img setImage:animalImage];
  2. self.img.animalImage.image=animalImage;

i tried all these but its not working.

Thanks in advance

A: 

Assuming img is the name of your UIImageView, [img setImage:animalImage]; is correct.

Verify that you've hooked img (which should be an IBOutlet) up to the UIImageView object in Interface Builder, as that's the most likely cause of your troubles (and most of us all on a regular basis!)

Kirk van Gorkom
Thanks to reply, problem is that i have missed *that is NSData *imageData
mac
+1  A: 

Is that a typo or you're really missing the * after NSData and UIImage déclarations ?

NSData* imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://dblog.com.au/wp-content/galah.jpg"]];
UIImage* animalImage = [[UIImage alloc] initWithData:imageData];

yonel
thanks to remember that i have missed *
mac