说我有以下内容:
UITextField *textField = [[UITextField alloc] init];
和模型对象:
JSModel *model = [[JSModel alloc] init];
以下内容将给我一个双向约束(也许这种方法存在缺点,我没有看到?):
RAC(model, text) = textField.rac_textSignal;
RAC(textField, text) = RACObserve(model, text);
如何使用[UITextField rac_newTextChannel]
来实现这种双向绑定?
答案 0 :(得分:11)
类似的东西:
RACChannelTerminal *textFieldTerminal = [self.textField rac_newTextChannel];
RACChannelTerminal *modelTerminal = RACChannelTo(self.model, text);
[modelTerminal subscribe:textFieldTerminal];
[[textFieldTerminal skip:1] subscribe:modelTerminal];