• 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: Lee Ann Rucker <email@hidden>
  • Date: Fri, 7 Jan 2011 12:31:23 -0800
  • Acceptlanguage: en-US
  • Thread-topic: NSDictionary key types

On Jan 7, 2011, at 10:36 AM, 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 ...]).
>
> I guess the long answer is "its complicated", and the short answer is "just use
> NSStrings".
>
> Thanks to all, I think I'm getting the hang of it.

The long and short answers are both "they won't". The non-trivial isEqual methods check the object's class; an NSString can be equal to an NSMutableString if their contents match, but never an NSNumber. Hash is a secondary check._______________________________________________

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: 
 >re: NSDictionary key types (From: Kirk Kerekes <email@hidden>)
 >Re: NSDictionary key types (From: Jon Sigman <email@hidden>)

  • Prev by Date: Re: Stupid png icons
  • Next by Date: Re: NSDictionary key types
  • Previous by thread: Re: NSDictionary key types
  • Next by thread: Re: NSDictionary key types
  • Index(es):
    • Date
    • Thread