• 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: NSDictionary key types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDictionary key types


  • Subject: Re: NSDictionary key types
  • From: Greg Guerin <email@hidden>
  • Date: Fri, 7 Jan 2011 13:44:36 -0700

Jon Sigman wrote:

The underlying issue I was having was how to know when different objects used as
keys might be reasonably expected to match, especially if they weren't generated
the same way (as with [NSNumber stringValue] and [NSString ...]).


That's easy: they match when isEqual: returns true.

See the NSDictionary class reference:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ Foundation/Classes/NSDictionary_Class/Reference/Reference.html


Find isEqual on the page:
"... no two keys in a single dictionary are equal (as determined by isEqual:)."


This subtly suggests that key equality is synonymous with isEqual:.

There is also a logical relationship between hash and isEqual, which must be maintained. Objects that are equal must also have equal hashes. Or: equality presupposes hash-identicality.

  -- GG





_______________________________________________

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


  • Prev by Date: Re: NSDictionary key types
  • Next by Date: Re: NSDocument updateChangeCount when using Bindings
  • Previous by thread: Re: NSDictionary key types
  • Next by thread: LOCATING MEDIA FILES IN MACINTOSH
  • Index(es):
    • Date
    • Thread