我有一个带有NSNotification的UITextField:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:@"UITextFieldTextDidChangeNotification" object:_searchTextField];
- (void)textFieldDidChange :(NSNotification *)notif
{
//
}
当我输入r
NSConcreteNotification 0x193c20 {name = UITextFieldTextDidChangeNotification; object = <UITextField: 0x15a980; frame = (20 20; 280 31); text = 'r'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x15aad0>>}
如何从notif对象中获取文本r
?
答案 0 :(得分:16)
通知的object
属性存储文本已更改的文本字段,因此notif.object.text
将包含文本“r”。