Re: NSArrayController subclass
Re: NSArrayController subclass
- Subject: Re: NSArrayController subclass
- From: Bertrand Landry Hetu <email@hidden>
- Date: Tue, 21 Sep 2004 12:06:27 -0700
I found the problem. NSArrayController implements
automaticallyNotifiesObserversForKey: and returns NO to everything but
what it explicitly supports...
Bertrand.
On 21 sept. 2004, at 01:10, Bertrand Landry Hetu wrote:
I tripled checked the nib file, the NSArrayController is using the
subclass, and I confirmed this by overriding the selectionIndexes
function and putting break points. I have a button that has the
"enabled" value bound to the canDoSomething controller key, no
keypath. The button never enables when something is selected. There
is not much code: the array controller is bound to the file's owner
array which is KVC comp., I have a couple of NSTableViews bound to
arrangedObjects and selectionIndexes and they are all working and KVO
is doing its job. canDoSomething is invoked initially when bind: is
invoked on the NSArrayController subclass, but not when the selection
changes, so I'm deducing the binding is working but it is lacking some
KVO event.
This function will become more complex later on, I kept it as simple
as possible to get this working.
-(BOOL)canDoSomething
{
NSIndexSet * indexes = [self selectionIndexes];
if ([indexes count] == 0)
return NO;
return YES;
}
Bertrand.
On 20 sept. 2004, at 23:13, Scott Stevenson wrote:
On Sep 20, 2004, at 10:35 PM, Bertrand Landry Hetu wrote:
I'm trying to do a subclass of NSArrayController that would add
accessors similar to canAdd, canRemove. And I'm running in the
following issue: I'm not getting changes as the selection changes.
I added [self setKeys: [NSArray arrayWithObject: @"selectionIndexes"
triggerChangeNotificationsForDependentKey: @"canDoSomething"] to my
+(void)initialize and I expected it to work but no.
I haven't tried this myself (maybe somebody else has), but can't see
offhand why it wouldn't work.
How did you use "canDoSomething"? Did you bind something to it or
register for notifications?
Are you sure you selected the subclass in IB?
In other words, what specifically isn't working? Can you post sample
code?
- Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden