Using NSImages as keys to a dictionary
Using NSImages as keys to a dictionary
- Subject: Using NSImages as keys to a dictionary
- From: "Lawrence Sanbourne" <email@hidden>
- Date: Sat, 13 May 2006 01:24:25 -0500
Hello,
My app needs a way of caching scaled images (thumbnails) so that they
aren't recreated each time. I first did this using an
NSMutableDictionary mapping from original image to scaled image.
However, this didn't work because apparently one original image wasn't
isEqual: to another.
I realized that I just wanted pointer equality. So I did this:
// originalIcon is an NSImage *
[cachedIcons objectForKey:[NSNumber numberWithInt:(int)originalIcon]];
It works beautifully. However, this code seems really weird to me. Is
there a better way?
Larry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden