Re: Representing hierarchy in NSPopupButtonCell
Re: Representing hierarchy in NSPopupButtonCell
- Subject: Re: Representing hierarchy in NSPopupButtonCell
- From: Jeff Watkins <email@hidden>
- Date: Tue, 14 Jun 2005 21:05:38 -0400
I've gone down the path of building an NSPopUpButtonCell directly
based on the contents of an NSArrayController. However, when I send
arrangedObjects to the popup, I get back an NSArray with 0 items.
However, in the next column, I have an NSPopUpButtonCell connected to
the same controller using bindings, and it reports the correct number
of items.
From my subclass of NSWindowController's windowDidLoad method, I
observe the arrangedObjects key of the NSArrayController (which
really does contain entries). I then call rearrangeObjects, which
triggers my observeValueForKeyPath:... method.
However, that's when everything stops working. I try to loop through
the array of entries in the arrangedObjects array, however, it has 0
elements.
I'm certain I'm missing something really simple.
Here's snippets from my app:
- (void) observeValueForKeyPath: (NSString*) keyPath
ofObject: (id) object
change: (NSDictionary*) changes
context: (void*) context
{
// Create a new button cell
NSPopUpButtonCell* categoryPopup= [[[NSPopUpButtonCell alloc]
init] autorelease];
[categoryPopup setBordered: NO];
// Fill the popup items
NSArray* categories= [categoryController arrangedObjects];
// the categories array doesn't seem to have any elements!
}
- (void) windowDidLoad
{
// Want to know when the arranged object list changes
[categoryController addObserver: self forKeyPath:
@"arrangedObjects"
options: (NSKeyValueObservingOptionNew)
context: NULL];
[categoryController rearrangeObjects];
}
I'd appreciate a little help with this. It doesn't seem like it
should be so hard...
Thanks,
Jeff
--
Jeff Watkins
http://metrocat.org/
_______________________________________________
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