Re: KVO on objects in NSArrayController
Re: KVO on objects in NSArrayController
- Subject: Re: KVO on objects in NSArrayController
- From: Dave Fernandes <email@hidden>
- Date: Sat, 03 Sep 2011 10:34:44 -0400
I'm coming late to this conversation, but couldn't you just add a -[MyObject setMarked:] method that would then be called to change the 'marked' attribute/property? It can do anything else it wants after making the change. Why use notifications at all? Is it some other object that needs to be notified when MyObject changes?
On 2011-09-03, at 1:22 AM, Trygve Inda wrote:
>> 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.
>>
>>
>
> I think this sounds like a much better option than trying to use KVO.
> Thanks!
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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