• 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
NSDictionary, keys, and equals
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: NSDictionary, keys, and equals
      • From: Art Isbell <email@hidden>
  • Prev by Date: Re: Is WebObjects Dead?
  • Next by Date: Re: Is WebObjects Dead?
  • Previous by thread: Re: Please Post RELEVANT topics?
  • Next by thread: Re: NSDictionary, keys, and equals
  • Index(es):
    • Date
    • Thread