David Janes' Code Weblog

November 28, 2009

UIImage imageNamed: and caching

code fragments,iphone · David Janes · 7:07 am ·

There may be some temptation to improve caching for UIImage imageNamed:

static UIImage* starred = nil;
if (starred == nil) starred = [UIImage imageNamed:@"starred.png"];

Don’t do this, it’s really stupid. It’s already being held by a cache, and maybe dropped out of it at any time, leading to miraculous crashes.

0 comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress

Switch to our mobile site