Bot
Bot

Reputation: 11845

Cocoa library for popup with different title from value

I am looking for the best approach to this issue. I have a PopUp Button with 4 entries in it. I would like the user to be able to change them, however when the popup button changes and I access the selected value, it will be my predefined value and not what they customized it to be.

Example

|Value1|
|Value2|
|Value3|
|Value4|

is my predefined. They may change them to

|1Value|
|2Value|
|3Value|
|4Value|

However when they select 3Value I need the code to see Value3.

Is there an already existing library that supports this? If not what would be the best approach to do something like this? This is for a Mac OS X Application.

Upvotes: 1

Views: 89

Answers (2)

Bot
Bot

Reputation: 11845

I ended up using coredata with a apieKey and displayValue. I then use a fetch request to get the key (original value) when needed.

Upvotes: 0

Mundi
Mundi

Reputation: 80265

In NSPopUpButton you will find a property indexOfItem. Just use the index to identify the items.

NSArray *original = // the values of the original items 
NSInteger *selected = [popUpButton indexOfItem:popUpButton.selectedItem];
id originalItem = [original objectAtIndex:selected];

Upvotes: 1

Related Questions