0

I've implemented the NSComboBoxDelegate:

-(void)comboBoxSelectionDidChange:(NSNotification *)notification{

}

- (void)controlTextDidEndEditing:(NSNotification *)aNotification{

}

- (void)comboBoxWillPopUp:(NSNotification *)notification{

}

- (void)comboBoxWillDismiss:(NSNotification *)notification{
}

but I have 2 comboBoxes - with 2 different functionalities. is there a way to know which comboBox is no on the run, and act accordingly?

or do I have to implement 2 different delegates outside? and if so - is there an easy way to transfer information back to my viewcontroller?

is there a way to get info about the sender of the notification?

Aviram Netanel
  • 12,633
  • 9
  • 45
  • 69

3 Answers3

3

For text change (controlTextDidEndEditing, controlTextDidChange...), see the following example.

- (void)controlTextDidEndEditing:(NSNotification *)obj {
    if ([obj object] == combobox1) {

    }
    else if ([obj object] == combobox2) {

    }
}

As for selection change, you need to create IBAction connections for respective objects.

El Tomato
  • 6,479
  • 6
  • 46
  • 75
1

The notification object ([notification object] or notification.object) will be the combo box that sent the notification.

JWWalker
  • 22,385
  • 6
  • 55
  • 76
0

Why don't you use tags? you can assign a tag 101 to one of them and a 102 to the other, then when they fire the delegate you just need to have an if clause to check the object's tag.

Flavio Silverio
  • 1,004
  • 8
  • 12