0

I have a property, recording, that changes to YES if a UILongPressGestureRecognizer is in state UIGestureRecognizerStateBegan or UIGestureRecognizerStateChanged.

How can I create an signal that will only fire when recording goes back to NO and not on its initial value?

jscs
  • 63,694
  • 13
  • 151
  • 195
Alex
  • 8,801
  • 5
  • 27
  • 31

2 Answers2

5

This would send @YES every time self.recording's value changes to YES, and ignore any NOs:

RACSignal *mySignal = [RACObserve(self, recording) ignore:@NO];

This would skip the initial value, regardless of whether it's NO or YES, and would send every subsequent value (either NO or YES):

RACSignal *mySignal = [RACObserve(self, recording) skip:1];

You can achieve more fine-grained control over how ReactiveCocoa KVOs your property using NSKeyValueObservingOptionNew to only send a value if the property gets set to a new (not the initial) value:

RACSignal *mySignal = [self rac_valuesAndChangesForKeyPath:@"recording" 
                                                   options:NSKeyValueObservingOptionNew
                                                  observer:self];
erikprice
  • 6,240
  • 3
  • 30
  • 40
2

Have you tried using the skip: method to skip the initial "NO" signal?

pNre
  • 5,376
  • 2
  • 22
  • 27