Re: KVO on objects in NSArrayController

2011-09-06 Thread Sean McBride
On Sat, 3 Sep 2011 09:23:43 -0700, Kyle Sluder said: >> I understand that... I think the alternative would be to register an >> observer on all 8000+ objects in the array. > >Yes, this is the expected pattern with KVO. Contrary to what you might >think at first, it is *fast*. Unless you are using

Re: KVO on objects in NSArrayController

2011-09-03 Thread Kyle Sluder
On Sat, Sep 3, 2011 at 12:12 AM, Trygve Inda wrote: > I understand that... I think the alternative would be to register an > observer on all 8000+ objects in the array. Yes, this is the expected pattern with KVO. Contrary to what you might think at first, it is *fast*. To use OmniPlan 2 as an ex

Re: KVO on objects in NSArrayController

2011-09-03 Thread Dave Fernandes
I agree, it is certainly a valid and useful design pattern that I use as well. But I just wasn't sure that it is needed in the OP's case. From the part that I read (and I missed the first part of the thread), there was no mention of which objects needed to be notified. On 2011-09-03, at 10:52 A

Re: KVO on objects in NSArrayController

2011-09-03 Thread Jerry Krinock
On 2011 Sep 03, at 07:34, Dave Fernandes wrote: > 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 notifi

Re: KVO on objects in NSArrayController

2011-09-03 Thread Dave Fernandes
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 n

Re: KVO on objects in NSArrayController

2011-09-03 Thread Quincey Morris
On Sep 2, 2011, at 23:34 , Jerry Krinock wrote: > Indeed it is, *if* you literally want the notification, as you said in your > original post, "whenever the user toggles a … checkbox". Sure. > However, if, as is more commonly the case, you actually need a notification > whenever the 'marked' a

Re: KVO on objects in NSArrayController

2011-09-03 Thread Trygve Inda
> > On 2011 Sep 02, at 22:22, Trygve Inda wrote: > >>> Briefly, you can configure the checkbox cell (either in IB or >>> programmatically) to have an action… > >> I think this sounds like a much better option than trying to use KVO. > > Indeed it is, *if* you literally want the notification, as

Re: KVO on objects in NSArrayController

2011-09-02 Thread Jerry Krinock
On 2011 Sep 02, at 22:22, Trygve Inda wrote: >> Briefly, you can configure the checkbox cell (either in IB or >> programmatically) to have an action… > I think this sounds like a much better option than trying to use KVO. Indeed it is, *if* you literally want the notification, as you said in yo

Re: KVO on objects in NSArrayController

2011-09-02 Thread Trygve Inda
> 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" c

Re: KVO on objects in NSArrayController

2011-09-02 Thread Quincey Morris
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

Re: KVO on objects in NSArrayController

2011-09-02 Thread Jerry Krinock
On 2011 Sep 02, at 19:01, Trygve Inda wrote: > 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). If you want to use KVO, yes. I recall some sample code, written by mmalc. I forgot if it was on stepwise.com (which mean

KVO on objects in NSArrayController

2011-09-02 Thread Trygve Inda
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