02.12.2012 23:14:00 • Categories: Objective-C • Tags: UIImage, Objective-C
Objective-C: create UIImage from URL
NSString* imageURL = @"http://theurl.com/image.gif"; NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imageURL]];UIImage* image = [[UIImage alloc] initWithData:imageData]; [imageView setImage:image]; [imageData release]; [image release];
//or nested version
UIImage* myImage = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: @"http://www.mydomain.com/image.png"]]]; [myImageView setImage:myImage]; [myImage release];