NSComboBoxDelegate called but old 'stringValue' remains
I select a value from the drop-down of a combo box. The NSComboBox delegate fires a comboBoxSelectionDidChange: notification, but when I retrieve the stringValue of the combo box, it's the old se开发者_运维百科lected value. How do I get the updated value?
I have a dataSource specified, so itemObjectValueAtIndex:
and objectValueOfSelectedItem
don't work.
If you’re using a data source, then:
NSString *s = [yourDataSource comboBox:comboBox
objectValueForItemAtIndex:[comboBox indexOfSelectedItem]];
should work if your data source provides strings. Otherwise, convert the object returned by this method to a string.
From here:
I got the selected value using:
NSString *strValue = [comboBox itemObjectValueAtIndex:[comboBox indexOfSelectedItem]];
精彩评论