RAC()和.rac_command不能一起工作

时间:2014-03-12 09:43:00

标签: reactive-cocoa

所以我的导航栏中有一个UIBarButtonItem,想要像这样使用RAC():

RAC(myButton, enabled) = [RACSignal 
  combineLatest:@[ RACObserve(self, password), RACObserve(self, passwordConfirmation) ] 
  reduce:^(NSString *password, NSString *passwordConfirm) {
    return @([passwordConfirm isEqualToString:password]);
  }];

但是rac_command在点击时也会被捕获,如下所示:

myButton.rac_command = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
  // Do stuff
  return [RACSignal empty];
}];

当我将这两者结合起来时,我得到一个断言错误。

所以问题是:我如何组合使用RAC()和rac_command?

1 个答案:

答案 0 :(得分:3)

改为使用-[RACCommand initWithEnabled:signalBlock:]

相关问题