Question

I have a NSCombobox that is binded to an Object Controller. The Object Controller is an instance of an (custom) Employee Class that is created via RestKit's object serialization framework. The NSComboBox's Value is binded to a key path employeeType, which is an int value stored on an remote MySql database. The int value corresponds to the employee type, so

0 == "Full Time" 
1 == "Part Time"
2 == "Terminated"
....
11 == "Temp Worker"

Currently (as expected), the NSComboBox displays the int value. Is there a way to invoke selectItemAtIndex: using that int value in IB so it selects the item at that index, not just putting the int value in the NSComboBox via bindings?

My thoughts were I could override the getter in a a property so it would look like:

if ([self employeeType] == 0) {
    [comboBox selectItemAtIndex:0];
}

But I don't believe this would be correct use of bindings.

Was it helpful?

Solution

Bind the pop-up button's "Selected Index" to your controller instead of "Selected Value". Here is a screen-shot to make things clearer:

Interface Builder - Bindings

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top