How to Load a UIImage From a URL

Dec 5, 2009   //   by Derek van Vliet   //   Development  //  1 Comment

Early on in development of Addicus, we discovered how easy it was to load images from the web. This was a huge boon to us since it meant our artists could modify assets on our server and they would update live in the test builds, without having to make a new build.

This all hinged on the ability to load a UIImage from a URL. And as it happens, this can be accomplished in as little as one line of code:

UIImage * img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://example.com/image.png"]]];

This eventually led to us writing a resource manager singleton class that handles all of our resource loading and can be toggled between local and web mode.

1 Comment

  • [...] Indicator with UIActivityIndicatorView 4. Eliminating class dependencies on your app delegate 5. How to Load a UIImage From a URL 6. How to Open the Mail App With a Pre-Composed HTML Email 7. How to Get the Current Time With [...]

Leave a comment

Our Games

Latest Tweets