dai*_*dai 10 iphone objective-c uitextfield nsnotification nsnotificationcenter
我有一个带有此NSNotification的UITextField:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:@"UITextFieldTextDidChangeNotification" object:_searchTextField];
- (void)textFieldDidChange :(NSNotification *)notif
{
//
}
Run Code Online (Sandbox Code Playgroud)
当我输入时,NSLog就是 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>>}
Run Code Online (Sandbox Code Playgroud)
如何r从notif对象中获取文本?
yuj*_*uji 16
通知的object属性存储文本更改的文本字段,因此notif.object.text将包含文本"r".