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

标签 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?

最佳答案

改用-[RACCommand initWithEnabled:signalBlock:]

关于reactive-cocoa - RAC() 和 .rac_command 不能一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22347423/

相关文章:

ios - ReactiveCocoa : How do you bind a button's title to a text property?

ios - ReactiveCocoa 4 - 延迟和过滤信号事件

ios - Reactive Cocoa 上的应用程序崩溃订阅 [UIButton rac_signalForControlEvents :]

ios - RACDelegateProxy 与 Common Delegate 实现

ios - RACSequence 和 RACSignal 有什么区别

objective-c - ReactiveCocoa 5.0 中的 RACObserve(object, keyPath)

swift - 信号 : Collect values over time interval

swift - 每次 UITextField 文本属性在 ReactiveCocoa 5 中更改时如何获得信号

ios - OCMock [OCMAnyConstraint isProxy] : message sent to deallocated instance, 发生了什么事?

ios - 如何使用 ReactiveSwift 将有错误的信号转换为 NoError 信号? (并且要优雅)