My iPhone app has a built in RSS reader. There are images and I'd like to find a way to cache them on th开发者_StackOverflowe system but have the system manage the caching and eventual clean up.
Is there a way of doing this?
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.
精彩评论