开发者

Can't populate NSMenu from document controller

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜