Re: KVO on objects in NSArrayController
Re: KVO on objects in NSArrayController
- Subject: Re: KVO on objects in NSArrayController
- From: Quincey Morris <email@hidden>
- Date: Fri, 02 Sep 2011 21:35:01 -0700
On Sep 2, 2011, at 19:01 , Trygve Inda wrote:
> I have an array of objects (of class MyObject) managed by an
> NSArrayController and displayed in an NSTable (via bindings).
>
> One property of MyObject is a BOOL "marked".
>
> I need to be notified whenever the user toggles a "marked" checkbox in my
> NSTable.
>
> What is the best way to do this? Do I need to add an observer to every
> object in the array (there are about 8,000 of them).
>
> How can I best achieve this so that I get passed the changed MyObject
> (immediately after it changes).
Briefly, you can configure the checkbox cell (either in IB or programmatically) to have an action, and possibly an explicit target. In the action method, you can use NSTableView's 'clickedRow' method to find the row and hence the object whose "marked" property changed, and send a message representing to the change directly to whatever object has to be notified.
_______________________________________________
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