Re: Manual binding questions.
Re: Manual binding questions.
- Subject: Re: Manual binding questions.
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 23 Jan 2005 20:18:13 -0800
On Jan 23, 2005, at 7:59 PM, Jiva DeVoe wrote:
So it seems like in order to handle those notifications, I have to
implement observeValueForKeyPath:ofObject:change:context: right? (Of
course, that makes sense now) but... it also appears, unless I am
mistaken, in order to get those notifications, I have to call
addObserver:forKeyPath:options:context ? If so... then what purpose
does bind:toObject:withKeyPath:options: serve?
bind:... is the method you call to establish the binding, to tell (for
example) the view what value it should keep in sync with what
controller property.
Within its bind:... method, the view should add itself as an observer
of the controller (see Listing 2 on
<http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Concepts/HowDoBindingsWork.html>).
This text from that doc tends to indicate the observation is set up
for me with this function:
" From the perspective of model-initiated updates the method can be
interpreted as follows:
toObject: GraphicController
If the GraphicController’s
withKeyPath:@"selection.shadowAngle"
selection.shadowAngle changes
bind:@"angle"
update whatever is associated with the exposed angle key
options:options
using the options specified (for example, using a value transformer).
The receiver therefore registered as an observer of the specified
object’s key path (selection.shadowAngle) in its
bind:toObject:withKeyPath:options: method, as was shown in Listing 2.
Observed objects notify their observers by sending them an
observeValueForKeyPath:ofObject:change:context: message. Listing 4
shows a partial implementation for the Joystick class for handling the
observer notifications that result."
I'm sorry if that's misleading. It assumes an appropriate
implementation of the bind:... method ("as was shown in Listing 2").
If so - then what purpose does the addObserver:forKeyPath.... function
serve?
addObserver:... registers an object to receive KVO change notifications.
mmalc
_______________________________________________
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