NSDictionary, keys, and equals
NSDictionary, keys, and equals
- Subject: NSDictionary, keys, and equals
- From: Jonathan Rochkind <email@hidden>
- Date: Wed, 25 Feb 2004 18:24:13 -0600
I want to use a custom object as a key in an NSDictionary. It's an
immutable object.
I have implemented a custom equals() on that custom object class.
(Don't worry, it's not an EO).
My impression was, if I stored an object in an NSMutableDictionary
under a certain key, it would be retrievable not only by that exact
same object (identity ==) as a key, but by _another_ object of the
same type that equals() the first object, even if it doens't == the
first object.
However, this does not seem to be the case. What's up with that? I
suppose I could serialize my thing into a String, and use that as a
key---and then so long as the two equals() objects serialized into a
string the same way, I'd know everything would be cool. But what's
up?
Is it the mysterious hashCode()? Cause I haven't actually provided a
custom implementation of hashCode(), I'm just using whatever
java.lang.Object gives me. Is this the problem?
--Jonathan
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.