Skip navigation.
 
mlRe: NSMenu and NSMenuItem help
FROM : Stéphane Sudre
DATE : Thu Jan 10 18:10:02 2002

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];


Related mailsAuthorDate
mlNSMenu and NSMenuItem help Jeff LaMarche Jan 10, 08:53
mlRe: NSMenu and NSMenuItem help Thomas Lachand-Rob… Jan 10, 09:43
mlRe: NSMenu and NSMenuItem help Jeff LaMarche Jan 10, 17:41
mlRe: NSMenu and NSMenuItem help Jeff LaMarche Jan 10, 17:45
mlRe: NSMenu and NSMenuItem help Stéphane Sudre Jan 10, 18:10
mlRe: NSMenu and NSMenuItem help Thomas Lachand-Rob… Jan 10, 19:21