Re: Re: Confused about bindings
Re: Re: Confused about bindings
- Subject: Re: Re: Confused about bindings
- From: "Julien Jalon" <email@hidden>
- Date: Sun, 19 Nov 2006 17:30:25 +0100
On 11/19/06, David Aames <email@hidden> wrote:
Okay... Thanks for the explanation. But as I was reading through the
docs ("View Initiated Updates", Bindings Programming Guide) it says
the view has to send the new values to the controller ("Communicate
view values to the controller to which it is bound") and the method
call they show is:
[observedObjectForAngle setValue: newControllerAngle forKeyPath:
observedPathForAngle];
But doesn't this actually bypass the controller? E.g. the
observedPathForAngle might be @"selection.shadowAngled" so what this
call is doing is just getting [observedObjectForAngle selection] and
calling the setValue method on the selection so it actually
communicates the values to the model and not the controller.
-[NSController selection] returns a proxy (managed by the controller)
to the model object. You don't bypass the controller.
So are
we actually supposed to use KVC to update the model objects ourselves
(i.e. implement in on our own in our custom views)? If that is the
case wouldn't it be better to implement the updating in the setters
and not in updateForMouseEvent: as it is shown in the docs? Thanks.
Yes: your custom views has to handle the whole stuff itself (and
that's where Apple documentation and code examples is a little bit
lacking)
No: you should consider that your setters in your view are not a way
to modify the model but a way for the controller to reflect model's
changes. (and in facts, you can test that using -[NSControl setValue:]
directly won't change the model's value and will likely to make your
control out-of-sync with the model).
--
Julien
_______________________________________________
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