Re: NSMenu and NSMenuItem help
Re: NSMenu and NSMenuItem help
- Subject: Re: NSMenu and NSMenuItem help
- From: Jeff LaMarche <email@hidden>
- Date: Thu, 10 Jan 2002 08:41:34 -0800
On Thursday, January 10, 2002, at 12:43 AM, Thomas Lachand-Robert wrote:
What is surprising? RTFM. NSMenuItem doesn't respond to itemAtIndex (it
makes sense: a menu item doesn't have pieces inside). You are confusing
with NSMenu. Why do you cast that way to NSMenu* BTW ? Certainly the
compiler has warned you that putting an NSMenu* in an NSMenuItem* is
incorrect: read the warnings, and read the doc, too. Similarly the
assignment to appMenu is incorrect.
Thank you for your assumption that I didn't read the manual. Now, let's
discuss the problem and the reality, because I did not post a question
without reading, I spent several hours trying to figure this out. The
compiler was NOT warning, and an NSMenu CAN contain NSMenus (submenus)
as well as NSMenuItem. Perhaps you should have RTFM before you responded.
So, to elucidate the problem: When I dump the item retrieved by the
first call to itemAtIndex to NSLog, it tells me quite clearly that I
have retrieved a submenu which is an NSMenu (Apple Menu), but when I go
to send it an itemAtIndex, which it should respond to, but it doesn't,
telling me that NSMenuItem doesn't respond to itemAtIndex. The cast was
something I added trying to figure the problem out, not a part of the
original code, and I forgot to remove it before posting this (late at
night when I was tired).
So, instead of berating me, perhaps you could tell me why the compiler
is telling me that I have pulled down an NSMenuItem * when NSLog is
telling me I've pulled down an NSMenu? Or why I get a runtime error but
not a compiler warning (yes, even without the cast). Certainly the item
at index 0 of my main application menu is the Apple menu, which is an
NSMenu and not an NSMenuItem. And if you don't know the answer, kindly
say nothing because I don't need crap from self-righteous people, which
fortunately there are not a lot of on this list.