监听AlertViewController的文本输入框的内容

[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        //这里需要添加观察者
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(search:) name:UITextFieldTextDidChangeNotification object:textField];
    }];
//实现观察方法
- (void)search:(NSNotification *)noti {
    UITextField *textfield = noti.object;
    self.alertText = textfield.text;

}
原文地址:https://www.cnblogs.com/arenouba/p/5358068.html