Using Reactive cocoa to monitor UIT patterns?

Im pretty new for reactive cocoa and im trying to incorporate FRP elements into the game I'm trying to build. From my Internet search, the resources and documentation for Reactive cocoa seem very limited, and most tutorials use the same examples!

What I want to do is to have RACSignal, which gives a stream of values ​​for the current touch on the view (for simplicity, don't allow multiple clicks). And then use subscribeNext to perform my actions when the UITouch object becomes mutated. I have a problem setting the RAC signal itself!

Im currently doing the following (which is not sure if this is the right way!)

  @interface MyView:UIView{

      UITouch *currentTouch;
      RACSignal *touchSignal;
  }
  @property(nonatomic , assign)UITouch *currentTouch;



  @implementation MyView
  @synthesize currentTouch;

  -(id)init{
     if(self = [super init]){

    }
    return self;
  }

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

   NSArray *touchArray = [touches allObjects]; 
   for(UITouch *touch in toucheArray){   
       currentTouch = touch;  
       if(!touchSignal){
           touchSignal = [RACObserve(self , currentTouch) distinctUntilChanged];
       }

    }

}

, RACSignal , :

 [MyView rac_valuesForKeyPath:observer:]: unrecognized selector sent to instance 0x2084cf90

? RACSignal? , touchSignal (, MyView) ?

+4
1

, -rac_signalForSelector:. , ( , ).

RACSignal *touchSignal = [[[self
    rac_signalForSelector:@selector(touchesBegan:withEvent:)]
    reduceEach:^(NSSet *touches, UIEvent *event) {
        return [touches anyObject];
    }]
    distinctUntilChanged]
+2

All Articles