59082

Question:
cocoa newbie here
i have 2 nstextfields connected with controlTextDidChange. it works fine.
- (void)controlTextDidChange:(NSNotification *)anotif{
[self eval];
}
when either of the textfields change eval is called.
what i want to do is check the textfield that changed and if it's the first one call eval1, if it's the second call eval2.
how can i do this?
Answer1:Given that the NSTextField
s are field1
and field2
, all you have to do is check which one of them is the sender object, given along with the notification.
<strong>E.g.:</strong>
- (void)controlTextDidChange:(NSNotification *)anotif
{
if ([anotif object]==field1)
{
// field1 processing
}
else
{
// field2 processing
}
}
Answer2:OK, I think I found it.
I set tags on both NSTextField
s.
Then, I can get the tag number with :
[[anotif object] tag]