• 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: Relationship between -isEqual and -hash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Relationship between -isEqual and -hash


  • Subject: Re: Relationship between -isEqual and -hash
  • From: Dustin Voss <email@hidden>
  • Date: Sun, 21 Jan 2007 22:27:18 -0800

On 19 Jan 2007, at 1:46 PM, Jeffrey J. Early wrote:

Quick question:

It is well stated in the documentation that the following must be true:

If two objects are equal (as determined by the isEqual: method), they must have the same hash value.

My question is whether the reverse must also hold?

I assume because it's not mentioned in the documentation (and I can't think of a reason why), it must be okay.... but that isn't necessarily good reasoning :-)

In my code I have a dictionary that I want to behave in a particular way. I'm using objects as keys where if two objects are 'close enough', they will return the same value from the dictionary, even if these objects aren't equal in the -isEqual: sense. So when objects are 'close enough', I have them return the same hash value.

It's all laid out here: http://cocoadev.com/index.pl?HashingAndEquality _______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Relationship between -isEqual and -hash (From: "Jeffrey J. Early" <email@hidden>)

  • Prev by Date: Re: My Core Data experiences
  • Next by Date: Multiple Menus in NSPopupButtonCell / NSTableView
  • Previous by thread: Re: Relationship between -isEqual and -hash
  • Next by thread: alternating row background color and custom row height bug?
  • Index(es):
    • Date
    • Thread