It it trivial to set up an NSArray containing strings and connect (via an NSArrayController) the content array to an NSPopUpButton (a nice answer for this standard problem is here, NSPopUpButton + Bindings + Show All Option).
I have a NSPopUpButton and want each item in the menu to draw using a view (it has been possible to add views to menu item since 10.5 using the -setView:
method of NSMenuItem).
So far I have the following approach.
1) A model object which provides the views,
@interface MenuViewsModel : NSObject
// Array of views for the pop up button to display
@property NSArray *previewViews;
@end
2) In IB I add an array controller to my XIB and set it's content array as the previewViews
of model.
3) Next I bind the NSPopUpView to the array controller:
- Content - > arrayController.arrangedObjects
- Content Values -> arrayController.arrangedObjects
The pop-up menu displays the pointers of the views as strings rather than taking the views and setting the NSMenuItem's view
property. For example the pop-up button displays items like,
< NSView: 0x61000014e910 >
< NSView: 0x61000014e9c0 >