Re: KVO and isKindOfClass:
Re: KVO and isKindOfClass:
- Subject: Re: KVO and isKindOfClass:
- From: "Timothy J.Wood" <email@hidden>
- Date: Thu, 17 Mar 2005 13:16:40 -0800
On Mar 17, 2005, at 12:51 PM, patrick machielse wrote:
Never realized this, but couldn't you just use
if (![otherObject isKindOfClass:[self class]])
so you compare to the class of the 'clone'?
Seems better to not have the class's name hard wired too.
That won't work either. 'otherObject' might be of MyClass and self
might be of NSNotifying_MyClass, and with the two classes being peers
this will fail.
Also, note that using [self class] is fragile in a different way than
hard-coding the class. If you have a subclass of MyClass, then your
-isEqual: would start returning "is equal as far as the common
superclass is concerned" instead of "is equal". Also, using [self
class] here will cause you to start getting [A isEqual:B] != [B
isEqual:A] when A is an instance of a subclass of B's class. Equality
is typically expected to be symmetric.
Another school of thought would be to use [self class] ==
[otherObject class], but that has problems of its own (and would also
break due to this KVO bug :)
-tim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden