• 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
Re: NSDictionary key types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDictionary key types


  • Subject: Re: NSDictionary key types
  • From: Jon Sigman <email@hidden>
  • Date: Thu, 6 Jan 2011 13:39:06 -0800 (PST)

On Jan 6, 2011, at 1:24 PM, David Duncan wrote:


> The short of it is that its a value that allows you to quickly tell if
>something is worth looking at more closely for equality. As a real world example
>a hash code is equivalent to saying "this object is short, this object is tall"
>without breaking out a ruler to determine if they are the same length.

-----

Okay, so the take-away from all this is that for the purpose of using objects as
keys, I can rely on two NSStrings hashes being equal if their string values are
equal; the same goes for two NSNumbers, etc. (though NSNumber might be a more
problematic case since it can be evaluated in numerous different ways, -int
-float, ...?).

If I've understood everything correctly, then the following two (contrived)
objects have the same hash value and will return TRUE from -isEqual:

  id myStr1 = @"8760";
  id myStr2 = [[NSNumber numberWithInt:8760]stringValue];



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSDictionary key types (From: Jon Sigman <email@hidden>)
 >Re: NSDictionary key types (From: Nick Zitzmann <email@hidden>)
 >Re: NSDictionary key types (From: Jon Sigman <email@hidden>)
 >Re: NSDictionary key types (From: Nick Zitzmann <email@hidden>)
 >Re: NSDictionary key types (From: Jon Sigman <email@hidden>)
 >Re: NSDictionary key types (From: Nick Zitzmann <email@hidden>)
 >Re: NSDictionary key types (From: Jon Sigman <email@hidden>)
 >Re: NSDictionary key types (From: David Duncan <email@hidden>)

  • Prev by Date: Re: LOCATING MEDIA FILES IN MACINTOSH
  • Next by Date: Re: Context in GCD source cancel handler?
  • Previous by thread: Re: NSDictionary key types
  • Next by thread: Re: NSDictionary key types
  • Index(es):
    • Date
    • Thread