Skip to content

Instantly share code, notes, and snippets.

@jakemarsh
Created January 11, 2012 20:35
Show Gist options
  • Save jakemarsh/1596622 to your computer and use it in GitHub Desktop.
Save jakemarsh/1596622 to your computer and use it in GitHub Desktop.
Interview Question
There is no right answer, just want to get an idea how you would attack the problem.
You have a UITableView that displays images from a web service, you want to make sure it loads those images in a performant, memory conscious way, how would you do it?
@hamrickdavid
Copy link

  • Have some sort of queue to download images
  • Draw the images when they are ready and you aren't scrolling
  • Cache the images either on disk or in memory

Questions

  • Are these images that need to be cached? Or will they just be displayed once? You wouldn't want to have to reload the image from a URL just because you've scrolled up and down a page
  • Are the images going to change on the server? Or how will you know when to invalidate your cache?

@andyzaharia
Copy link

Yep, UIImageView+WebCache can do the job too :)

@ccjensen
Copy link

probably use NSOperation rather than libdispatch, as you want the ability to cancel an image download if that image scrolls off screen. Once the image has been downloaded, it would make sense to cache them/store them in an object so that if the user is scrolling up and down we don't have to re-download stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment