开发者

Can't populate NSMenu from document controller

开发者 https://www.devze.com 2022-12-16 23:06 出处:网络
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 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

精彩评论

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

关注公众号