• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating Menu Items Programmatically.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating Menu Items Programmatically.


  • Subject: Re: Creating Menu Items Programmatically.
  • From: Nick Zitzmann <email@hidden>
  • Date: Thu, 13 Feb 2003 03:52:45 -0800

On Thursday, February 13, 2003, at 03:23 AM, Steve wrote:

1) What's the most convenient way to just turn the (long)portNum in to a string that initWithTitle will accept?
(I don't really have to write NSNumber and formatting code do I??)

Are you trying to create NSMenuItems with numbers for titles?

2) The selector (which is part of the same controller class) is not being called. I have an idea that the newly created items might mistakenly think the First Responder is the target.

long portNum;
NSMenuItem *menItem;
for( portNum=1; portNum <=numInputs; portNum ++)
{
menItem = [NSMenuItem alloc];
[menItem initWithTitle :portNum:@selector(setInputPort) keyEquivalent:@""];
[menuInPort addItem:menItem];
}

This looks incorrect to me. Assuming you're naming each menu item by the value of portNum, try this instead:

long portNum;
for( portNum=1; portNum <=numInputs; portNum ++)
{
[menuInPort addItemWithTitle:[NSString stringWithFormat:@"%ld", portNum] action:@selector(setInputPort:) keyEquivalent:@""];
}

(Note: Written in Mail, untested.)

Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page: http://dreamless.home.attbi.com/

#include <stdsignature.h>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Creating Menu Items Programmatically. (From: Steve <email@hidden>)

  • Prev by Date: Re: Creating Menu Items Programmatically.
  • Next by Date: Re: Strange Error with Singleton Class
  • Previous by thread: Re: Creating Menu Items Programmatically.
  • Next by thread: Re: Creating Menu Items Programmatically.
  • Index(es):
    • Date
    • Thread