Remote High-Resolution Images
Adding high-resolution artwork to an iOS 4 project is extraordinarily easy; all you need to do is add the new files to your project in a particular format (imagename@2x.png alongside an existing imagename.png), and UIImage will automatically load the appropriate file depending on the screen scale.
However, if you're loading images remotely, you'll need to do some of the work yourself. Here's an example of how to fetch a gravatar portrait depending on the device resolution:
float size = 40.f;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 4.0) {
size = size * [[UIScreen mainScreen] scale];
}
NSString *url = [NSString stringWithFormat:@"http://www.gravatar.com/avatar/%@?s=%i", emailHash, size];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
// implement the NSURLConnectionDelegate methods,
// and use the resulting data in [UIImage initWithData:data];
As you can see, it's relatively straightforward: just grab the screen scale from [[UIScreen mainScreen] scale] and use it to determine the resolution of the image you want to download.