Re: Cocoa bindings one- or bi-directional
Re: Cocoa bindings one- or bi-directional
- Subject: Re: Cocoa bindings one- or bi-directional
- From: mmalcolm crawford <email@hidden>
- Date: Fri, 27 May 2005 03:18:12 -0700
On May 27, 2005, at 2:49 AM, Zdzislaw Losvik wrote:
This is at best misleading. The code specifies binding, not
observing. The basic goal of binding is to keep two values
synchronised. If you use the bind:... method to bind a text
field's 'value' to a keypath in an object controller, you could
get the expected behaviour.
I have read a dozen of articles about bindings. Some of them were
great. When I was done I was convinced that bindings always work
two-ways. The basic article by Apple about a joystick
( HowDoBindingsWork ) has lots of sample impementation code.
Although I have read it several times, until yesterday, I was sure
that this glue code is already implemented in NSObject. But NO,
user has to write it for his class by himself. Basic NSView
subclasses have these methods implemented, but when you use your
custom view this has to be added.
Given that one of the main aspects of the article is illustrate how
you should go about implementing a bindings-enabled view (as a
vehicle to giving a more in-depth understanding of the technologies
the allow bindings to work), I'm not sure why you would have thought
that the implementation is already provided in NSObject?
I have tried rewriting my code to bind brick1 to NSObjectController
(brick2) - it makes no difference. brick1 observes brick2, but
reverse is not true.
You haven't changed the fundamental configuration (binding two model
objects), you've just introduced an intermediary.
So that nobody would complain that I am having a bad practice of
not using controller and binding two model objects together - in my
application bindigns look this way:
NSViewSubclass bound to NSObjectController that controlls
NSObjectSubclass
And it makes no difference.
It's not clear exactly what is the problem in this case? You mean
that your view subclass is not sent KVO notifications, or that the
model is not updated when the view changes, or both, or something else?
It seems to me that bindings are not fully implemented in Mac OS X.
It is just a bit odd that so much advertised technology does not
work as it is supposed to. Values are not kept in sync. Probably
there was a reason of doing so.
Bindings do work correctly when they're used in accordance with the
design guidelines.
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