Re: Wisdom of overriding isEqual:
Re: Wisdom of overriding isEqual:
- Subject: Re: Wisdom of overriding isEqual:
- From: Wade Tregaskis <email@hidden>
- Date: Thu, 11 Mar 2004 11:54:29 +1100
...since if the argument is an NSString, it can't be equal to the
receiver, obviously
Ummm... obviously? I *DO NOT* advocate it is right, but I can well
imagine a very sensible design in which, say, an NSAttributedString
would be truly "equal" to a NSString of the same contents, attributes
ignored...
I don't want to argue, you are most probably right. Only I wanted to
point out that, at least in principle, different classes *may* be
equal.
Well, in this case I'm pretty sure NSAttributedString is a subclass of
NSString (or part of it's class cluster), so isKindOfClass:[NSString
class] would return YES for it. Consequently isEqualToString: would
then be called.
You may be right, however, in that it may use isMemberOfClass: rather
than kind, since subclasses (like NSAttributedString) could well have
additional data which NSString doesn't know about, so isEqualToString
may erroneously return YES. In fact, I'm pretty sure this is the case,
now that I think about it.
FWIW, it's the scenario where two classes of separate inheritance may
be equal where you would most likely want to override isEqual.
Wade Tregaskis
-- Sed quis custodiet ipsos custodes?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.