Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UITextFieldTextDidChangeNotification中的文本_Iphone_Objective C_Uitextfield_Nsnotificationcenter_Nsnotification - Fatal编程技术网

Iphone UITextFieldTextDidChangeNotification中的文本

Iphone UITextFieldTextDidChangeNotification中的文本,iphone,objective-c,uitextfield,nsnotificationcenter,nsnotification,Iphone,Objective C,Uitextfield,Nsnotificationcenter,Nsnotification,我有一个带有此通知的UITextField: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:@"UITextFieldTextDidChangeNotification" object:_searchTextField]; - (void)textFieldDidChange :(NSNotification *)notif {

我有一个带有此通知的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>>}
NSConcreteNotification 0x193c20{name=UITextFieldTextDidChangeNotification;object=}

如何从notif对象中获取文本
r

通知的
对象
属性存储其文本已更改的文本字段,因此
notif.object.text
将包含文本“r”。

它给出了一个错误-在类型为'id'do
[(UITextField*)notif.object text]的对象上找不到属性'text'
是的,所以我必须:UITextField*txt=(UITextField*)notif.object;NSlog(@“%@”,txt.text);您应该使用常量UITextFieldTextDidChangeNotification(在UITextField.h中声明),而不是将自己的NSString作为“name”参数传递