• 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: When do I need to override hash?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When do I need to override hash?


  • Subject: Re: When do I need to override hash?
  • From: Clark Cox <email@hidden>
  • Date: Wed, 19 Aug 2009 18:40:51 -0700

On Wed, Aug 19, 2009 at 6:19 PM, Seth Willits<email@hidden> wrote:
> On Aug 19, 2009, at 4:28 PM, Gideon King wrote:
>
>> So do I need to override hash too? If so, are there any recommendations as
>> to how to determine the hash easily?
>
> I probably shouldn't admit this, but I've yet to override hash and have yet
> to notice any problems. The docs say I should, so I realize I likely should,
> but I would really like a concrete reason to do so. I've never called hash,
> nor seen it ever called by anyone else's code. I assume the frameworks call
> it from somewhere, but where?


If you've ever put those objects in an associative or hashing
container (NSSet, NSDictionary keys, NSHashMap NSHashTable, etc.),
you're probably sitting on obscure, hard to find bugs.


In general, if you override -isEqual:, you should override -hash. Period.

--
Clark S. Cox III
email@hidden
_______________________________________________

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

References: 
 >When do I need to override hash? (From: Gideon King <email@hidden>)
 >Re: When do I need to override hash? (From: Nathan Vander Wilt <email@hidden>)
 >Re: When do I need to override hash? (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: FYI - new debug & profile libraries are out: Installer Refuses
  • Next by Date: Re: When do I need to override hash?
  • Previous by thread: Re: When do I need to override hash?
  • Next by thread: RE: When do I need to override hash?
  • Index(es):
    • Date
    • Thread