Re: NSDictionary key types
Re: NSDictionary key types
- Subject: Re: NSDictionary key types
- From: Greg Guerin <email@hidden>
- Date: Fri, 7 Jan 2011 13:44:36 -0700
Jon Sigman wrote:
The underlying issue I was having was how to know when different
objects used as
keys might be reasonably expected to match, especially if they
weren't generated
the same way (as with [NSNumber stringValue] and [NSString ...]).
That's easy: they match when isEqual: returns true.
See the NSDictionary class reference:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/
Foundation/Classes/NSDictionary_Class/Reference/Reference.html
Find isEqual on the page:
"... no two keys in a single dictionary are equal (as determined
by isEqual:)."
This subtly suggests that key equality is synonymous with isEqual:.
There is also a logical relationship between hash and isEqual, which
must be maintained. Objects that are equal must also have equal
hashes. Or: equality presupposes hash-identicality.
-- GG
_______________________________________________
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