Re: Double binding not possible?
Re: Double binding not possible?
- Subject: Re: Double binding not possible?
- From: Ken Thomases <email@hidden>
- Date: Fri, 11 Jun 2010 09:59:45 -0500
On Jun 11, 2010, at 9:33 AM, vincent habchi wrote:
> I have a popUp button with which I'd like to update two objects at the same time (one with the selected index, and the other with the selected value). Can you confirm me it is impossible (once one binding of the selected type is set, the other get greyed out).
Yes, it is impossible.
Those bindings are two-way. (Not all are, but those are.) Thus, when the bound-to property changes, so does the view's selection. Now, how would this work if the view's selection were bound to two different properties? What if those properties were inconsistent with each other?
Out of curiosity, which two objects were you binding to? That may suggest a design problem. Or do you mean two properties of the same object? Usually, a view binding is bound to a property of a controller.
If you want the controller to present the selection in two different ways, you can define one property to be computed from another property. You make a getter which doesn't consult a dedicated instance variable, but rather consults the other property. Then, you implement +keyPathsForValuesAffecting<Key> with <Key> being the capitalized name of the computed property and have it return a set including the name of the stored property.
Then, clients of the controller can consult or observe either property, whichever is more convenient, and they will get the correct value.
Regards,
Ken
_______________________________________________
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