Re: Why aren't my bindings firing?
Re: Why aren't my bindings firing?
- Subject: Re: Why aren't my bindings firing?
- From: Steve Weller <email@hidden>
- Date: Sat, 28 Jun 2008 07:26:43 -0700
On Jun 28, 2008, at 2:55 AM, Ken Thomases wrote:
Also interestingly, the only reference to the
bind:toObject:withKeyPath:options: method that comes up in an API
search of the documentation is from the NSKeyValueBindingCreation
protocol, which states this:
"Establishes a binding between a given property of the receiver and
the property of a given object specified by a given key path."
Since this doesn't seem to be actually the case, someone ought to
file a report on the documentation about this.
Yeah, and the description of the "binding" parameter of that method
also says it's a "key path for a property of the receiver", which
contradicts my understanding (as we've been discussing).
So, my curiosity piqued, I did some more reading. The "Bindings"
chapter of the Cocoa Fundamentals Guide <http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_6.html
> also directly contradicts what I've been saying. It unambiguously
states that you can bind together any two objects so long as they're
KVC/KVO-compliant. Now _I'm_ confused -- and worried that I've been
spreading misinformation.
Note the terminology on that page:
" You can establish a binding between an attribute of a view object
and a property of a model object (typically through a mediating
property of a controller object)."
It refers to an "attribute", not a property or a key or key path. So I
am guessing that's the difference here: views override NSObject's
default property-based binding and replace it with an attribute-based
one. This allows two-way syncing to occur and prevents loops. Views,
since they allow the user to make changes, go the extra step of
propagating the change to the model as part of their binding
implementation. Regular non-view objects don't have this, so the
binding is one-way. They use KVC to see changes in the model value but
not to change the model value. Am I right?
[Stuff snipped]
None of this jibes with bindings as they're used in views. First,
there's that reference listing the bindings supported by various
classes. As discussed, the list for NSTextField is decidedly
shorter than the list of properties for which NSTextField is KVC/KVO-
compliant. That's generally true of most views listed in that
reference. Second, establishing a binding to a view is two-way,
while establishing non-view bindings is one-way.
It's time for mmalc to chime in and put everyone straight.
Steve Weller email@hidden
Technical Writing, Editing, Developer Guides, and a little Cocoa
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden