Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.mac.programmer.help > #46
| From | Daniel Höpfl <news@hoepfl.de> |
|---|---|
| Newsgroups | comp.sys.mac.programmer.help |
| Subject | Re: Building a menu at run-time with server-supplied data |
| Date | 2011-08-22 23:14 +0200 |
| Organization | albasani.net |
| Message-ID | <j2ugqt$oaq$1@news.albasani.net> (permalink) |
| References | <spamproof-21451A.19363919082011@news.eternal-september.org> |
Hi,
> void BuildPartsMenu(NSArray *TheParts)
> {
> id ThisPart;
> NSMenu *MenuBar = [NSApp mainMenu];
> NSMenu *PartMenu = [MenuBar itemWithTitle:@"Available Parts"];
NSMenu's itemWithTitle: returns a NSMenuItem, not a NSMenu.
And that's what Cocoa is telling you:
> 2011-08-19 18:43:32.956 TestHarness[6021] *** -[NSMenuItem addItem:]:
> selector not recognized [self = 0x43f0f0]
You probably want to change the line to something like
NSMenu *PartMenu = [[MenuBar itemWithTitle:@"Available Parts"] submenu];
You might want to change some more things:
- Besides the application name, menu titles usually consist of one word
only. ("Parts"?)
- You should not use the title to search for the menu. This will break
once you translate your NIB. Set a tag and itemWithTag: instead.
- Consider using "for(NSDictionary *thisPart in TheParts)" instead of
NSEnumeration.
- Read some Cocoa code. Most people use a different naming scheme.
- Set your breakpoints to a point *before* the problematic code not at
the end. Stepping through the code would have shown you the line that
triggers the error as well giving you the chance to inspect the
variables at this moment.
HTH,
Daniel
Back to comp.sys.mac.programmer.help | Previous | Next — Previous in thread | Find similar
Building a menu at run-time with server-supplied data Poster <spamproof@nowhere.invalid> - 2011-08-19 19:36 -0700 Re: Building a menu at run-time with server-supplied data Daniel Höpfl <news@hoepfl.de> - 2011-08-22 23:14 +0200
csiph-web