Re: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
Re: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
- Subject: Re: triggerChangeNotificationsForDependentKey in subclass of NSArrayController
- From: Shaun Wexler <email@hidden>
- Date: Thu, 7 Oct 2004 11:45:04 -0700
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
_______________________________________________
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