Re: NSMenu and NSMenuItem help
Re: NSMenu and NSMenuItem help
- Subject: Re: NSMenu and NSMenuItem help
- From: Stéphane Sudre <email@hidden>
- Date: Thu, 10 Jan 2002 18:10:02 +0100
On Thursday, January 10, 2002, at 08:53 AM, Jeff LaMarche wrote:
I'm trying to get a handle to one of the menu items in my application's
menu. I'm having two problems, first of all, when I get a sub-menu
using any of the itemAt... methods, it gives an uncaught exception when
I then send an itemAt message to the submenu, something like this:
NSMenu *appMenu;
NSMenuItem *item;
appMenu = [[NSApp mainMenu] itemAtIndex:0];
item = (NSMenu *)([appMenu itemAtIndex:1]); <----- Exception
raised: *** -[NSMenuItem itemAtIndex:]: selector not recognized
[NSMenuItem submenu]
so it should be
NSMenu *appMenu;
NSMenuItem *item;
appMenu = [[[NSApp mainMenu] itemAtIndex:0] submenu]];
[[appMenu itemAtIndex:1]submenu];