how to get uiimage
from a nsurl
other than using the method NSData *data = [NSData dataWithContentsOfURL:url];
There is another problem the ui elements are not working while a nsthread
is running

- 37,241
- 25
- 195
- 267

- 1,723
- 2
- 16
- 47
-
I would also like to know the answer. – Yama Dec 20 '11 at 10:40
5 Answers
Personally I tend to use NSOperationQueue.
See

- 5,403
- 1
- 21
- 26
I like to use ASIHttpRequest. It will be something like this.
ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL:url];
[request setCompletionBlock:^{
NSData * responseData = [request responseData];
UIImage * image = [UIImage imageWithData:responseData];
}];
[request setFailedBlock:^{
NSLog(@"Failed to load image : %@", [request.error localizedDescription]);
}];
[request startAsynchronous];

- 4,403
- 25
- 28
-
-
Why would you want to avoid NSData? (what's wrong with NSData...?) I thought the question was how to load UIImage without blocking. – barley Dec 20 '11 at 12:25
For background image download, you could try
https://github.com/AFNetworking/AFNetworking/

- 4,276
- 1
- 18
- 25
Go through this link:http://www.markj.net/iphone-asynchronous-table-image/
Download
AsyncImageView.h AsyncImageView.m
add these files to your project and import it in your class
write down these lines wher yu want to add imagesubview:
AsyncImageView *asyncImageView=[[AsyncImageView alloc] initWithFrame:CGRectMake (80, 10, 70,20);]; NSURL *url = [NSURL URLWithString:imageUrl]; [asyncImageView loadImageFromURL:url]; asyncImageView.backgroundColor=[UIColor clearColor]; [myimageView addSubview:asyncImageView]; [asyncImageView release];
you will get

- 250
- 2
- 2