• 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 19:03:42 -0000 (GMT)
  • Importance: Normal

> On Mar 19, 2009, at 11:18, email@hidden wrote:
>
>>> Based on what you've posted, your source code looks rather messed up.
>>> Presumably you have a NSArrayController subclass with a "targetPhoto"
>>> property. What kind of property? Is it an array object?
>>
>> Did you look at the code? The sample code is right there it will
>> tell you
>> what class it is.
>
> Er, sorry, operator error. I didn't scroll down past your signature
> and the blank lines that followed it.
>
>>> The first thing you need to do is to find all the error messages in
>>> your run log (and I suspect there are multiple errors, even before
>>> the
>>> exception) and post the actual message text.
>>
>> There is nothing in the log file except for the exception. that is
>> being
>> called when you call removeObserver... I guess you didn't run the
>> code..
>
> So what *is* the exception? (No, I'm not planning on running your
> code. What's important is the error message *you* got.)

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.'

Also in the debugger setting a breakpoint before the removeObserver

po [myTestArrayController observationInfo]

You will get:

<NSKeyValueObservationInfo 0x10c380> (
<NSKeyValueObservance 0x10da70: Observer: 0x10ac00, Key path:
targetPhoto.name, Options: <New: YES, Old: NO, Prior: NO> Context: 0x21,
Property: 0x10bce0>
)

and doing a further investigation on the observation info:

po 0x10bce0


<NSKeyValueNestedProperty: Container class: NSMyArrayController,
Relationship property: <NSKeyValueUnnestedProperty: Container class:
NSMyArrayController, Key: targetPhoto, isa for autonotifying:
NSKVONotifying_NSMyArrayController, Key paths of directly and indirectly
affecting properties: none>, Key path from related object: name>

Also the sample code I posted will work fine, in case you replace the
NSArrayController with NSObject.

But it will fail in case it is NSController, NSObjectController.

cheers,

marc

















_______________________________________________

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: Quincey Morris <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>)

  • Prev by Date: Extending supported document types at run time in doc-based app
  • Next by Date: Xcode & GoogleCode.
  • 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