I have two NSTextfield, and I want to use the same method for each one:
-(void)controlTextDidChange: (id)sender {
[label setStringValue:[textfield stringValue]];
}
I would like to use a different label/textfield couple depending on which NSTextField send the message. Is this information available in the sender object, or do I have to create a new delegate ?
The
[sender object]is yourtextfield, so getting thestringValueis easy. Getting the associated label, however, is not: you need to build your own scheme to find it.One way could be by marking your text fields by setting their
tagproperties to different numbers. If you set the tag of text field for the first label to 1 and the tag of text field for the second label to 2, you can do something like this: