1

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.

2 Answers 2

1

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];
2
  • this should work, however one concern is what if we do sorting of the edited items?
    – Bot
    Apr 15, 2013 at 23:53
  • That is another issue entirely. You can change the order of items dynamically in your data model by making the original array mutable.
    – Mundi
    Apr 16, 2013 at 7:03
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.