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 contr开发者_如何学编程oller 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?
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
精彩评论