Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSURL *url = [NSURL URLWithString:@"http://example.com/image.jpg"];
- NSData *data = [NSData dataWithContentsOfURL:url];
- UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];
- - (void)connectionDidFinishLoading:(NSURLConnection *)connection
- {
- if (requestData)
- {
- self.image = [[[UIImage alloc] initWithData:requestData] autorelease];
- }
- }
- [self performSelectorInBackground:@selector(loadImage) withObject:nil];
- - (void)loadImage
- {
- NSURL * url = [NSURL URLWithString:@"http://.../....jpg"];
- NSData * data = [NSData dataWithContentsOfURL:url];
- UIImage * image = [UIImage imageWithData:data];
- if (image)
- {
- // Success use the image
- ...
- }
- else
- {
- // Failed (load an error image?)
- ...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement