• 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: KVO and isKindOfClass:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: KVO and isKindOfClass:
      • From: "Timothy J.Wood" <email@hidden>
  • Prev by Date: Re: Odd NSData initWithContentsOfURL: issue
  • Next by Date: [OT] Looking for a rare bird (job offer)
  • Previous by thread: Re: KVO and isKindOfClass:
  • Next by thread: Re: KVO and isKindOfClass:
  • Index(es):
    • Date
    • Thread