• 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: Wisdom of overriding isEqual:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Re: Wisdom of overriding isEqual: (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: obj-c functions versus class methods
  • Next by Date: Re: Wisdom of overriding isEqual:
  • Previous by thread: Re: Wisdom of overriding isEqual:
  • Next by thread: Re: Wisdom of overriding isEqual:
  • Index(es):
    • Date
    • Thread