Re: Manual binding questions.
Re: Manual binding questions.
- Subject: Re: Manual binding questions.
- From: Jiva DeVoe <email@hidden>
- Date: Sun, 23 Jan 2005 21:41:50 -0700
Now I think I finally get it. Thank you very much! I had thought the
built in bind method somehow figured out how it should handle the
binding. I didn't realize I have to implement it myself. Is the
bind:toObject:withKeyPath:options: only needed if I am making a view
that I will be using on an IB palette? (ie: along with exposeBinding
etc?) Or do I need to implement that function even if I am only doing
the binding programmatically? It would seem, if I am doing the binding
programmatically, that I could simply addObserver for the attributes I
care about and go from there.
Again, thanks for the clarification.
On Jan 23, 2005, at 9:18 PM, mmalcolm crawford wrote:
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:
email@hidden
This email sent to email@hidden
--
Jiva DeVoe
jiva at devoesquared.com
http://www.devoesquared.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