Re: Comparing NSDictionary woes
Re: Comparing NSDictionary woes
- Subject: Re: Comparing NSDictionary woes
- From: Rosyna <email@hidden>
- Date: Sun, 22 Jul 2007 23:22:01 -0700
If they're not custom subclasses and the items in the dict are
members of a class cluster (NSString, NSArray, NSDictionary, et
cetera) there is a bug where isEqualToDictionary: will return NO in
some cases (such as if mutability differs) even if they are equal in
10.4.
However, your problem is a string problem?
I am not sure how isEqual: handles two different strings that are
rendered equal but have differing binary values (due to different
normalization forms, like NFD vs NFKD, see
http://en.wikipedia.org/wiki/Unicode_normalization). In this case,
you'd have to use a different compare value.
Ack, at 7/22/07, Chris Hanson said:
If they are custom subclasses of NSObject or some other class, and
you haven't implemented -isEqual: yourself, chances are they *don't*.
When implementing "value" classes, you *must* explicitly implement
-isEqual: and -hash on your objects in order for them to compare
identical based on their contents. Otherwise, your class will fall
back to -[NSObject isEqual:] which is a pointer-equality test and
-[NSObject hash] which isn't based on the contents of the object.
Also, you should have unit tests for your classes so you can say for
certain whether -isEqual: and -hash are behaving correctly. (The
rule is that -hash must return the same value for objects that
respond YES to -isEqual:, but objects that respond NO to -isEqual:
don't necessarily need different hashes.)
--
Sincerely,
Rosyna Keller
Technical Support/Carbon troll/Always needs a hug
Unsanity: Unsane Tools for Insanely Great People
It's either this, or imagining Phil Schiller in a thong.
_______________________________________________
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