Re: KVO and isKindOfClass:
Re: KVO and isKindOfClass:
- Subject: Re: KVO and isKindOfClass:
- From: patrick machielse <email@hidden>
- Date: Thu, 17 Mar 2005 21:51:04 +0100
Op 17-mrt-05 om 21:03 heeft Timothy J.Wood het volgende geschreven:
On one of my model classes, I have an -isEqual: method that does:
- (BOOL)isEqual:(id)otherObject;
{
if (![otherObject isKindOfClass:[MyClass class]])
return NO;
...
}
But, if this is sent to an object that has been targeted for KVO,
it's isa gets replaced with NSNotifying_MyClass which is NOT a
subclass of MyClass, but instead appears to be a clone of MyClass.
This seems to me to be a pretty big bug in KVO, but I'm wondering if
there is some design reason for this that I'm not considering. It
does make it hard to deal with class membership tests, though since
you might be comparing two objects, one of which has KVO listeners and
one of which doesn't (in either order).
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.
patrick
_______________________________________________
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