On Dec 27, 2009, at 12:01 PM, Jeremy Matthews wrote:

> Currently, I have a nspopupbutton with some general values "Airbus", 
> "Southwest", "Delta", etc...upon making the proper selection and clicking the 
> "generate" button, it creates the event with said attributes, including the 
> URL. So, I have a list of about 10 items in that popup, and a loooong if 
> statement. Depending on the selectedItem of the nspopupbutton, it grabs the 
> associated url and stuffs it into the method and returns the event.
> 
> Normally, I'd take a switch/case approach here, but I've been warned about 
> doing so in Cocoa.
> 
> Any ideas?
> It works fine now, but I know that there has to be a more graceful approach.

This is a job for -[NSMenuItem representedObject].  Set a represented object 
for the menu items in the menu associated with the pop-up button.  The 
represented object can be anything you like.  It can be just an NSURL.  If you 
need multiple pieces of data associated with each menu item, the represented 
object can be a dictionary.

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to