Not receiving notifications on NSArrayController selection changes
Not receiving notifications on NSArrayController selection changes
- Subject: Not receiving notifications on NSArrayController selection changes
- From: Ken Tozier <email@hidden>
- Date: Sun, 5 Jul 2009 23:58:18 -0400
Hi
I have an NSArrayController bound to an NSArray and am not getting
notifications either through my "setXXX method or through explicit
"addObserver" links.
The property in my class is defined like so:
@interface PMXMainPaletteToolbar : NSView
{
IBOutlet NSPopUpButton *site;
NSDictionary *siteRecords;
NSString *currentSite;
NSArrayController *siteController;
}
The array controller is initialized like so
- (void) initTools
{
siteRecords = [[PMInterfaceController invocation]
invokeWithSelector: @"get_sites_simple" arguments: @""];
siteController = [[NSArrayController alloc] initWithContent:
siteRecords];
// bind popup content to array controller array (This works. Popup is
populated correctly)
[site bind: @"content" toObject: siteController withKeyPath:
@"arrangedObjects.name" options: nil];
// even though class has a currentSite property, a currentSite method
and a setCurrentSite method
// the setCurrentSite method is never called when bound to the array
controller
[self bind: @"currentSite" toObject: siteController withKeyPath:
@"selection.name" options: nil];
// When above binding failed, I tried to explicitly define a
listener to the "selection" and "selectionIndexes" property of
siteController
// but neither observer gets called in response to menu selections.
[siteController addObserver: self
forKeyPath: @"selectionIndexes"
options: NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew
context: NULL];
// When both of those failed, I tried to listen for the selectedValue
of the popup
[site addObserver: self
forKeyPath: @"selectedValue"
options: NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew
context: NULL];
// that failed as well. My "observeValueForKeyPath" is never called.
}
So the question is, how the heck does one get real time notifications
to user selections in a popup menu?
Thanks for any help
_______________________________________________
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