Re: Binding a unique-selection checkbox in a table view?
Re: Binding a unique-selection checkbox in a table view?
- Subject: Re: Binding a unique-selection checkbox in a table view?
- From: Rick Mann <email@hidden>
- Date: Sat, 22 Nov 2014 12:42:58 -0800
> On Nov 22, 2014, at 03:17 , Jerry Krinock <email@hidden> wrote:
>
>
>> On 2014 Nov 21, at 19:09, Rick Mann <email@hidden> wrote:
>>
>> In an OS X app I have an NSTableView that binds to an array of Job objects. I'd like to have a checkbox column that the user can check that indicates the "active" job. There should be only one of these. Is there a way to bind the value of that column to something other than the Job for that row, to handle this?
>
> This uniqueness of the “active” job seems to me like it belongs in your data model, not your view controller.
It is in the data model. But it's currently smelly. When the active property gets set, that entity checks with the AppDelegate (it could be any object) to see who the currently-active instance was, and unsets that one. I don't like having my model know about the AppDelegate, but I don't see a way to bind to something else directly and say "if I am the same as this other thing, then check the widget. If the widget gets checked, make me the active thing on this other thing."
>
> If this is a quickie project, implementing the uniqueness in an IBAction method, as discussed yesterday, is a quick fix that will work.
>
> But for long-term projects that might in the future support, say, other views or scripting, Cocoa Bindings can be used to provide a more disciplined model-view-controller separation. Cocoa Bindings do have a development cost, quite a bit of baggage, but you’re already using Cocoa Bindings in this project anyhow.
>
>
> _______________________________________________
>
> 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
--
Rick Mann
email@hidden
_______________________________________________
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