• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using NSImages as keys to a dictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Using NSImages as keys to a dictionary
      • From: "Pontus Ilbring" <email@hidden>
    • Re: Using NSImages as keys to a dictionary
      • From: Greg Hurrell <email@hidden>
    • Re: Using NSImages as keys to a dictionary
      • From: Andrew Bowman <email@hidden>
  • Prev by Date: Re: Should objects returned by indirection be autoreleased
  • Next by Date: Re: Using NSImages as keys to a dictionary
  • Previous by thread: Re: Implementing -willDisplayCell... delegate method for NSMatrix [SOLVED]
  • Next by thread: Re: Using NSImages as keys to a dictionary
  • Index(es):
    • Date
    • Thread