Skip navigation.
 
mlRe: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
FROM : Shaun Wexler
DATE : Thu Oct 07 20:45:04 2004

On Oct 7, 2004, at 10:44 AM, Gabriele de Simone wrote:

> I think you are misunderstanding what
> automaticallyNotifiesObserversForKey: does. If you return NO, you are
> just declaring the intention to call willChangeValueForKey: and
> didChangeValueForKey: yourself (which is what I am doing in the
> example). Even if I change my code to return YES for myKey (from
> automaticallyNotifiesObserversForKey: of course), the notification for
> the dependent key is not sent.
>
> Again, the point of the question is not that I don't want to call
> rearrangeObjects, but to understand why the notification is not being
> triggered.


See, the way Cocoa bindings knows that myKey changed is because it
substitutes a subclass of your class, somewhat transparently to the
runtime, and overrides your method -setMyKey: thus vectoring it thru a
notification method which wraps your actual method IMP with the
will/did change notifications, as well as any dependent notifications. 
The only way Cocoa bindings can issue these dependent notifications for
you is if you DON'T disable them by returning NO when it queries your
class... returning YES from the method
+automaticallyNotifiesObserversForKey: tells the bindings layer it is
okay to take care of this for you, as I've described above.  If you
want to override this behavior, simply return NO and issue your own
notifications.  This is why it's not working for you; you've disabled
notifications, including dependent ones.  There's nothing wrong with
this, other than now you have to do everything yourself in -setMyKey:

HTH~
--
Shaun Wexler
MacFOH
http://www.macfoh.com

Related mailsAuthorDate
mltriggerChangeNotificationsForDependentKey in subclass of NSArrayController Gabriele de Simone Oct 7, 17:57
mlRe: triggerChangeNotificationsForDependentKey in subclass of NSArrayController Shaun Wexler Oct 7, 18:09
mlRe: triggerChangeNotificationsForDependentKey in subclass of NSArrayController Gabriele de Simone Oct 7, 19:44
mlRe: triggerChangeNotificationsForDependentKey in subclass of NSArrayController Shaun Wexler Oct 7, 20:45
mlRe: triggerChangeNotificationsForDependentKey in subclass of NSArrayController Gabriele de Simone Oct 7, 22:15
mlRe: triggerChangeNotificationsForDependentKey in subclass of NSArrayController Jacob Lukas Oct 8, 05:33
mlRe: triggerChangeNotificationsForDependentKey in subclass of NSArrayController Steven Kramer Oct 9, 15:46