ReactiveCocoa:为什么rac_textSignal不起作用

时间:2017-06-20 14:42:05

标签: ios objective-c reactive-cocoa

为什么这不起作用:

[self.phoneTextField.rac_textSignal subscribeNext:^(NSString *text) {
    self.viewModel.textFieldText = text;
}];

虽然效果很好,但即使点击了清除按钮:

RAC(self.viewModel, textFieldText) = RACObserve(self.phoneTextField, text);

1 个答案:

答案 0 :(得分:1)

rac_textSignal仅在UIControlEventAllEditingEvents触发时触发,并且不会发生清除。以下是两种情况的解决方法:

[[RACSignal 
  merge:@[self. phoneTextField.rac_textSignal, RACObserve(self.phoneTextField, text)]] 
  subscribeNext:^(NSString* text) {
      // do something here
  }];

BR,