Re: NSDictionary key types
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