Re: Bindings and To-Many Relationship
Re: Bindings and To-Many Relationship
- Subject: Re: Bindings and To-Many Relationship
- From: Quincey Morris <email@hidden>
- Date: Fri, 13 Jun 2008 11:54:16 -0700
On Jun 13, 2008, at 10:39, Milen Dzhumerov wrote:
I've got a question regarding bindings and to-many relationships.
I've got my own array controller which has a arrangedObjects
property. It is KVO observable as in notifications are sent when
objects are added / removed (and obviously if the actually content
array changes). Now my question is regarding KVO and any paths which
go through arrangedObjects - for example, if some object wants to
receive notifications for arrangedObjects.name, how do I handle this?
Conceptually, whose responsibility is it when someone wants to
observe arrangedObjects.name? Is it the array controller's or is it
whoever is interested? I've seen the GraphicsBindings example where
the sample code subscribes to receive notification for each object's
"name" path rather than observing arrangedObjects.name. I'm a bit
puzzled which route to take since it seems that NSArrayController
allows observation of arrangedObjects.name.
Does anyone know how NSTableColumn handles this?
NSArrayController's arrangedObjects doesn't exactly have a "name"
property. arrangedObjects is an array, and it happens to respond to
valueForKey:@"anyKeyYouWant" by returning an array of the
"anyKeyYouWant" property values of its elements. Whether or not you
want to call this a property of arrangedObjects, it's most certainly
not an *observable* property of arrangedObjects.
A similar point came up yesterday. When you use NSArrayController,
there's no "arrangedObjects.name" keypath involved. There's an array
controller and its "arrangedObects" keypath, bound from a table column
and its "name" keypath. The way that IB displays such a binding, as
"MyController.arrangedObjects.name", is just a shorthand description
of the binding, not an actual keypath.
_______________________________________________
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