• 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: Jeff Laing <email@hidden>
  • Date: Fri, 21 Aug 2009 04:09:20 +0000
  • Acceptlanguage: en-US
  • Thread-topic: When do I need to override hash?

> Core Data doesn't use random objects as keys in dictionaries or sets
> for this reason.  It's not that we don't trust you, but ...  to
> prevent misunderstandings, all NSManagedObject subclasses are
> forbidden from overriding -hash and -isEqual.

I have to admit, I didn't know this bit but I see it in the developer library along with a bunch of others.

> If you need to know whether or not another object has put your object
> into an NSDictionary, you're probably doing something wrong.  Do you
> have a specific concern about Core Data using your objects ?

No, I guess the point I was trying to make was that this discussion seemed to have touched on "if you put your objects into an NSSet then you'll need to be more careful about the implementation of -hash, etc".  I was trying to point out that just because my application code doesn't go anywhere near NSSet, its conceivable (to me) that Core Data (for example) might be storing dirty objects in an NSSet "behind your back". So you can't "not implement -hash, etc properly" and hope everything will work.

There may be any number of "external" technologies (Core Data was just an example) that may be using your objects in ways you aren't expecting, and there's no future-proof way you can cut corners.

_______________________________________________

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

  • Follow-Ups:
    • Re: When do I need to override hash?
      • From: Ben Trumbull <email@hidden>
    • Re: When do I need to override hash?
      • From: Clark Cox <email@hidden>
References: 
 >RE: When do I need to override hash? (From: Ben Trumbull <email@hidden>)

  • Prev by Date: Editable NSTextFieldCell with clickable button?
  • 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