Re: Manual binding questions.
Re: Manual binding questions.
- Subject: Re: Manual binding questions.
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 23 Jan 2005 20:59:30 -0800
On Jan 23, 2005, at 8:41 PM, Jiva DeVoe wrote:
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.
In a custom view you should implement your own
bind:toObject:withKeyPath:options: method.
The same bind:... method is called whether you establish the binding
programmatically or using IB.
You can't really just call the addObserver:... method directly (with
the view as the observer) -- you would miss out on additional set-up
required by the view. In particular (assuming it is editable), the
view needs to record the information specified in the bind:... method
so that it knows what to update if its value is modified (see
"View-Initiated Updates"). Moreover, however, if you just used
addObserver:... :
(a) There is no way to specify any value transformers for the "binding";
(b) You cannot easily specify a context for the observation -- this may
be useful to disambiguate observer notifications when they are received
(recall that all KVO notifications invoke
observeValueForKeyPath:ofObject:change:context:, so you need a way to
determine why a notification has been received -- see "Model-Initiated
Updates").
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