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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to