Q:

How to add a pop-up menu to a NSToolbarItem? 

I'm trying to open a pop-up menu from a NSToolbarItem.  I tried following this example but  I can't use that class method because NSToolbar and NSToolbarItem inherit from NSObject and not from NSView. 
Apart from creating a custom view, what is the best way to open a pop-up menu from a NSToolbarItem? 

A:

Basically, you create something like an NSButton that has an NSMenu attached to it, then use NSToolbarItem's setView: method to embed the button in the toolbarItem. 

A:

Just create an NSView in IB with your menu like you want it.  Then in your window controller, add some code like this:
// This assumes you have a window property pointing to the window to which you'll
// add the toolbar.  It also assumes you've connected the NSView to add to the
// toolbar to a member called toolbarView. 

- (NSArray*)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar {
    return [NSArray arrayWithObject:@"myToolbarMenu"];
}

- (NSArray*)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar {
    return [self toolbarAllowedItemIdentifiers:toolbar];
}

- (NSToolbarItem*)toolbar:(NSToolbar*)toolbar
    itemForItemIdentifier:(NSString*)str
willBeInsertedIntoToolbar:(BOOL)flag
{
    if ([str isEqualToString:@"myToolbarMenu"] == YES) {
        NSToolbarItem* item = [[NSToolbarItem alloc] initWithItemIdentifier:str];
        [item setView:toolbarView];
        [item setMinSize:[toolbarView frame].size];
        [item setMaxSize:[toolbarView frame].size];
        return [item autorelease];  
    }
    return nil;
}

- (void)windowDidLoad {
    NSToolbar* toolbar = [[NSToolbar alloc] initWithIdentifier:@"myToolbar"];
    [toolbar setDelegate:self];
    [self.window setToolbar:[toolbar autorelease]];
}

A:

If you want an actual pop-up button for the toolbar item, set an NSPopUpButton as the toolbar item's view. 
In Interface Builder 3.2.1 (I don't know when this ability was actually introduced), you can drill down to the toolbar in the hierarchical list of objects in the nib window, and drag a pop-up button from the Library palette into the toolbar in the list.  IB will wrap the button in a toolbar item for you.