开发者

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]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜