Downloading Images More Efficiently

Discussion in 'iOS Programming' started by harryslotwiner, Apr 27, 2012.

  1. harryslotwiner macrumors newbie

    Mar 28, 2012

    So I have an application in which I am downloading a fair share of images and putting them into UIImageViews like so
    ImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString: imageURL]]];
    The problem is that this is at the launch of the application and can take 10-15 seconds which is agonizingly boring to watch, is there any way that I could load them in a more efficient manor (Without lowering the image quality)?

    If not, in your opinion is it preferable to wait 10-15 seconds at the launch of the application, or have the app delay about half a second when you swipe to the next image set?

    Thanks for any help.
  2. larswik macrumors 68000

    Sep 8, 2006
    Are you using any kind of a background load like NSThread or GCD?

    I just uploaded my first app Wednesday to the app store and in my app I am downloading a bunch on images in the background while I present the user the rootViewController for them to interact with. If they click on something that is not loaded yet I display a loading bar to show it's progress.
  3. harryslotwiner thread starter macrumors newbie

    Mar 28, 2012
    Hey, I wasn't and that was the problem.

    To answer my own question, I found a really great "Framework" of sorts that is a really easy to implement and program to. It's just a slight adaptation to a UIImageView that keeps all of the normal attributes while adding simple image settings methods like:
    imageview.imageurl = @"";
    And then it runs the image loading threads in the background.

    And it also seems to use much less resources. I found a significant drop in memory that my application was using. So I highly recommend checking it out here:

    Thanks for the response though.
  4. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    You can also download the images once, store them in a local database/documents, and at startup check if any images are already downloaded, and if so, use the ones from the database, otherwise lazy load them from the internet so it doesn't block the interface :)

Share This Page