I have a NSAlert with a combobox in it and i need to know it s value every time it changes.
In my .h i have implemented the NSComboBoxDelegate
protocol and NSComboBox* comboBox
.
In my .m i have:
[comboBox setDelegate:self];
- (void)comboBoxSelectionDidChange:(NSNotification *)notification{
int x = [[comboBox stringValue] intValue];
NSLog(@"ComboBox Value Changed to --> %i", x);
}
But here is the problem:
the default value of the combobox is 2. if i change the value to, for example, 6 my NSLog
displays: ComboBox Value Changed to --> 2
Then, when i change it s value back to 2, my NSLog
displays: ComboBox Value Changed to --> 6
Any ideas about this problem?
Thank you.
PS:我已经尝试过其他 NSComboBoxDelegate
方法,但发生的情况与上述我所描述的相同。