Re: Updating bound controls with selection change
Re: Updating bound controls with selection change
- Subject: Re: Updating bound controls with selection change
- From: Ari Benzane <email@hidden>
- Date: Wed, 22 Aug 2007 17:28:50 +0100 (BST)
mmalc crawford <email@hidden> wrote:
On Aug 22, 2007, at 5:41 AM, Ari Benzane wrote:
> I have an inspector panel with a host of controls bound to the
> values of the currently 'selected' object in the document. Only one
> object can be selected at a time. When the selection changes, I want
> the bound controls to reflect the new selection, but they don't get
> notified because I'm not calling the KVO accessors.
>
Well, there's the problem...
How are you determining what is the current selection?
I have an NSController object in the NIB bound to the setSelection method in my document which is working ok.
What are the bindings for the controls?
Numbers mostly. Thats working fine, privided I call the relevent accessors. The controls are bound to keys in the NSController object which represents the selected object in the doc.
What other examples have you looked at and compared with?
Lots! But I've not seen anything quite like my project. I'm only partially using bindings (ie. all my tables use datasources etc).
> Currently I've got code like this that's called when the selection
> changes:
> [SelectedObject setValueA: [SelectedObject valueA]];
> [SelectedObject setValueB: [SelectedObject valueB]];
>
By convention, names of instances of classes start with a lowercase
letter; class names begin with an uppercase letter.
Yes I know. This was pseudo code.
> This updates the controls in a round-about way but it's a mess. Is
> they're an easier way? I've read Apple's Bindings and KVO docs but
> they only cover the simple cases.
>
In essence, every case is simple. You need a suitable key path and
you need to ensure that KVO notifications are emitted when a change is
effected.
So how can I ensure said notifications are displatched when the NSController object changes with the selection?
---------------------------------
For ideas on reducing your carbon footprint visit Yahoo! For Good this month.
_______________________________________________
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