• 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: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys


  • Subject: Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys
  • From: email@hidden
  • Date: Thu, 19 Mar 2009 22:16:30 -0000 (GMT)
  • Importance: Normal

> On Mar 19, 2009, at 12:03, email@hidden wrote:
>
>> In this narrowed down code of the bug it will log this on
>> removeObserver
>> (please ignore the Terminating app due to uncaught exception
>> 'NSInternalInconsistencyException', reason) because  I just created
>> simple
>> main sample code to narrow it down:
>>
>> *** Terminating app due to uncaught exception
>> 'NSInternalInconsistencyException', reason: 'Cannot remove an observer
>> <Observer 0x10ac00> for the key path "targetPhoto.name" from
>> <NSMyArrayController 0x1099d0>, most likely because the value for
>> the key
>> "targetPhoto" has changed without an appropriate KVO notification
>> being
>> sent. Check the KVO-compliance of the NSMyArrayController class.'
>
> This is not a lot of help to you, but I vaguely remember a discussion
> on this list a couple of months ago about problems with KVO on
> subclassed NSArrayControllers. I can't find the thread, but I did find
> that someone has been here before you:
>
> 	http://www.cocoabuilder.com/archive/message/cocoa/2008/4/15/204196

good catch i didn't find that one, at least i made some simple sample code
to point out the bug to Apple Developers, so hopefully they can address it
now.

> Why it should fail is not clear, but it may be that the code that adds
> observers does something special with NSArrayControllers (but doesn't
> realize your class is a subclass, or can't work properly if it's a
> subclass).
>
> Alternatively, it may be a side effect of the well-known defect in
> NSArrayController where its KVO notifications don't contain the proper
> new/old values.
>
> If I understand your workaround correctly, it bypasses (what we assume
> to be) NSArrayController's own overrides of didChange.../
> willChange... . That may get your custom property observer
> notifications to work properly, but my guess is that this will break
> (some) behavior of any objects using the NSArrayController's usual
> notifications.

 I call [super didChange... for non-custom keys and  I'm calling NSObject
didChange in case it is my custom key. So hopefully this address that
issue...

I haven't tested my patch long enough to say it will work 100% in all
scenarios but at least in the app I'm working on everything seems to work
ok so far... (need a few more days of testing before..).


> A better workaround strategy might be to avoid subclassing
> NSArrayController, and find another way to achieve what subclassing
> was going to get for you.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys
      • From: Marc Van Olmen <email@hidden>
References: 
 >Bug+Fix: NSController (and subclasses) have problems with custom KVO keys (From: email@hidden)
 >Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys (From: Quincey Morris <email@hidden>)
 >Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys (From: email@hidden)
 >Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys (From: Quincey Morris <email@hidden>)
 >Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys (From: email@hidden)
 >Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: any recommended zip framework ?
  • Next by Date: Re: problems with CAAnimation - SOLVED (kinda)
  • Previous by thread: Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys
  • Next by thread: Re: Bug+Fix: NSController (and subclasses) have problems with custom KVO keys
  • Index(es):
    • Date
    • Thread