controlTextDidChange with 2 nstextfields - 调用不同的选择器 [英] controlTextDidChange with 2 nstextfields - call different selectors
本文介绍了controlTextDidChange with 2 nstextfields - 调用不同的选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可可新手这里
我有2个nstextfields与controlTextDidChange连接。
它工作正常。
- (void)controlTextDidChange:(NSNotification *)anotif {
[self eval];
}
当调用任一文本字段更改eval时。
我想要做的是检查更改的文本字段,如果是第一个调用eval1,
如果是第二次调用eval2。
我如何做到这一点?
解决方案
由于 NSTextField
s field1
和 field2
,所有你需要做的是检查其中的哪一个是发送者对象
code> - (void)controlTextDidChange:(NSNotification *)anotif
{
if([anotif object] == field1)
{
// field1 processing
}
else
{
// field2 processing
}
}
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?
解决方案
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.
E.g.:
- (void)controlTextDidChange:(NSNotification *)anotif
{
if ([anotif object]==field1)
{
// field1 processing
}
else
{
// field2 processing
}
}
这篇关于controlTextDidChange with 2 nstextfields - 调用不同的选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文