Scott McKenzie
Scott McKenzie

Reputation: 16242

Caching images in iPhone app

My iPhone app has a built in RSS reader. There are images and I'd like to find a way to cache them on the system but have the system manage the caching and eventual clean up.

Is there a way of doing this?

Upvotes: 0

Views: 1023

Answers (1)

Jaanus
Jaanus

Reputation: 17866

Three20 does decent image caching. You don't need the rest of it, just look at TTImageView which is a drop-in replacement for UIImageView. You just do

someImageControl.urlPath = @"http://example.com/your/image.jpg";

And TTImageView handles the rest, including caching on disk etc.

I only have two minor problems with this approach myself:

  • for some reason, it does not seem to load all image formats, even if the image is valid JPG/PNG otherwise. Haven't yet debugged this.
  • I am not sure how it handles the cleanup part. I notice some images are sometimes disappearing from cache and refreshed from network, but it has not bothered me enough to investigate. It "just works."

TTImageView has some other nice properties that I don't have to waste my time on, e.g there is a placeholder image that you can ship with your app that is shown until the real image loads from network, etc.

Upvotes: 3

Related Questions