I could not find a clean way to add separators to the menu dynamically when using bindings. The easiest (and most reusable) way I've found is to use NSMenuDelegate to dynamically replace NSMenuItems with a specific header like @"---" with separator elements in the delegate method menuNeedsUpdate:
Step 1: Create an NSObject that Complies with the NSMenuDelegate Protocol
#import <Cocoa/Cocoa.h> @interface SeparatorMenuDelegate : NSObject <NSMenuDelegate> @end @implementation SeparatorMenuDelegate -(void)menuNeedsUpdate:(NSMenu *)menu { NSArray* fakeSeparators = [[menu itemArray] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"title == '---'"]]; for (NSMenuItem* fakeSep in fakeSeparators) { [menu insertItem:[NSMenuItem separatorItem] atIndex:[menu indexOfItem:fakeSep]]; [menu removeItem:fakeSep]; } } @end
Step 2: Link things in Interface Builder.
Drag the object into the scene containing the NSPopupButton instance. 
Define SeparatorMenuDelegate Object Class

Twirl open the NSPopupButton control in the outline of the document and select Menu from it. Then set the menu delegate to the SeparatorMenuDelegate object that you migrated earlier.

After that, all items in the menu with the heading @ "---" will be converted to separator items.
If you have multiple instances of NSPopupButton in the same scene, you can set the delegate of your menu to the same object (you only need one SeparatorMenuDelegate for each scene).
n.Drake
source share