I'm trying to figure out how a
NSPopUpButton is filled with data when using core data and cocoa bindings. The reason is that I subclassed
NSPopUpButton and I would like to manipulate the insertion of the menu items by adding an image to them.
- (void)addItemWithTitle:(NSString *)title,
- (void)addItemsWithTitles:(NSArray *)itemTitles and
- (void)insertItemWithTitle:(NSString *)title atIndex:(NSInteger)index just to see which method is called but none of them is on application start.
Does anybody know what's the correct method . The class reference doc isn't very helpful here (or I didn't get it how to use it) as there are no other methods listed which affect the item insertion.
Thanks in advance, Thomas
This is how you fill your NSPopUpButton with data from CoreData:
Let's say you have the CoreData entity "Person" with the NSString property "name"
First create an NSArrayController in InterfaceBuilder and set it's mode to "Entity Name", enter the name "Person" and check "Prepares Content".
Now put a new NSPopUpBotton in your Interface and bind it's "Content Values" to the ArrayController. The Controller Key should be "arrangedObjects" and the Model Key Path "name".
(Now you just have to add some data)
A NSPopUpButton contains NSMenuItems. NSMenuItems can have an image. So you don't have to subclass it.
You could also create an Array with NSMenuItems, which have images and bind the Array to "Content" of your NSPopUpButton.