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 (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 [EMAIL PROTECTED]

Reply via email to