Re: Wisdom of overriding isEqual:
Re: Wisdom of overriding isEqual:
- Subject: Re: Wisdom of overriding isEqual:
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 11 Mar 2004 11:47:28 -0500
on 2004-03-11 9:32 AM, Patrick Machielse at email@hidden wrote:
>
Knowing that it overrides isEqual: is only half way there. I'd like to know
>
what the implementation does. As it stands, only classes that define
>
isEqualTo...: have documentation stating when two objects are considered
>
equal if you store them in, for instance, an NSSet. For classes that do not
>
have a documented 'isEqualTo..:' method you have to 'trust' Cocoa to do the
>
right thing.
I think this is right, but it shouldn't be too difficult to figure out in
the case of standard Foundation classes.
It is extremely unlikely that data classes would rely on the NSObject
implementation of -isEqual:, because it does memory address comparison only.
That would almost never be appropriate in the case of a data object that
might by copied rather than retained for any number of reasons.
Equality of strings is described in the -isEqualToString: documentation, and
it is almost certain that -isEqual: calls this. Ditto for NSData,
NSDictionary, etc.
Are there any Foundation data classes that don't explain what their
-isEqualTo...: method does?
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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.