Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another newbie question



What I'd suggest is to assign each selection with a tag number in IB (or programatically if need be). Then in your code you can get the tag:

int colorID = [[colorButton selectedItem] tag];

Assign each its corresponding ID as the tag like 4 for black, 1 for red, ect.


On May 29, 2008, at 10:22 PM, Paul Archibald wrote:

Hi, its me again.

My interface consists (mostly) of a bunch of popup buttons with various values in them. Out user will set up all these popups and click "go", and the app will emit a string which can be used to run a command line program. So, for example we have a couple of popups like:

Color
-black
-red
-green
-blue

Size
-small
-medium
-large

So, lets say that the command line wants something like:
	"runfoo -color 2 -size 1"

and that the "runfoo" help file says
	-color : red = 1, blue = 2, green = 3, black = 4, default = 4
	-size : small = 1, medium = 2, large = 3, default = 3

So, here is my question. What is the best way to translate between the popup item and the value? I was thinking of building an NSDictionary with item_string_key/command_line_argument_value pairs, but I realized that I have a bunch of different "default" values (color default = 4, size default = 3).

I guess I could have a dictionary for each popup, but that seems clunky. I see there is something called "Bindings" for menu/popup items, is that a way to go? (I am trying not to put the info in the NIB, I would prefer code, where I can see it.)

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden
References: 
 >Another newbie question (From: Paul Archibald <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.