views:

52

answers:

1

Hi all,

I've a MainMenu.xib and a MyDocument.xib. I need to dynamically populate some NSMenuItem's from my document controller but I'm at a loss on how to get to it from MainMenu.xib.

I've tried adding an NSObject to MainMenu.xib and make it an instance of my document controller but I can't populate the NSMenuItem's from the NSArrayController I have on the controller.

Should I just do this in code or is there another way of tackling this?

+1  A: 

In MyDocument.m:

- (void)windowControllerDidLoadNib:(NSWindowController *) aController

try this:

NSMenu * mainMenu = [[NSApplication sharedApplication] mainMenu];

See Introduction to Application Menus and Pop-up Lists in Apple docs for more

stefanB