views:

127

answers:

1

I'm working on an application that talks home to a server and retrieves some data with image URL's embedded in it. I want to display those images on the view, and am getting them like so:

UIImageView *ivAvatar = [[UIImageView alloc] initWithImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.avatarUrl]]]];
[self.view addSubview:ivAvatar];
[ivAvatar release];

However, whenever data is retrieved (for example, on startup of the application), there is a delay between the retrieval of the data and the user being able to interact with the application due to the blocking nature of dataWithContentsofURL.

What is the proper way to do "Asynchronous" downloading of images? I need the UI to be responsive and load all other data that is retrieved, but load the images while allowing the UI to be responsive.

Any suggestions?

+1  A: 

NSURL, NSURLRequest, and NSURLConnection.

tc.
Could you direct me to an example of how these work together?
Mike Trpcic
Tutorial with code: http://www.dimzzy.com/blog/2009/11/remote-image-for-iphone/
progrmr