comboBoxSelectionDidChange给我以前选择的值 [英] comboBoxSelectionDidChange gives me previously selected value

查看:143
本文介绍了comboBoxSelectionDidChange给我以前选择的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将此通知用于NSComboBox.唯一的问题是,当我在下拉列表中选择其他项目时,它始终会在组合框中显示以前选择的值.如何获得当前选择的值.我需要根据值使一些控件启用/禁用.

I am using this notification for NSComboBox. Only problem is when I select a different item in the dropdown it always show previously selected value in the combo box. How can I get the currently selected value. I need to make some controls enable/disable based on the value.

- (void)comboBoxSelectionDidChange:(NSNotification *)notification {
        NSComboBox *comboBox = (NSComboBox *)[notification object];

        NSLog(@"[comboBox stringValue] : %@", [salaryBy stringValue] );
}

推荐答案

我使用以下方法获得了所选值:

I got the selected value using:

NSString *strValue = [comboBox itemObjectValueAtIndex:[comboBox indexOfSelectedItem]];

这篇关于comboBoxSelectionDidChange给我以前选择的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆