Can I delegate t开发者_开发百科wo NSComboBoxes to one comboBoxSelectionDidChange: method and run an if statement to differentiate between the two boxes?
I believe this may be a case where you can use NSNotification
's object method to obtain a pointer to the combo box that triggered the notification.
For example:
Assuming you have something like this in your .h file:
@interface MDAppController : NSObject {
IBOutlet NSComboBox *comboBox1;
IBOutlet NSComboBox *comboBox2;
}
@end
In your .m file:
- (void)comboBoxSelectionDidChange:(NSNotification *)notification {
NSComboBox *comboBox = (NSComboBox *)[notification object];
if (comboBox == comboBox1) {
// do something
} else if (comboBox == comboBox2) {
// do something else
}
}
精彩评论