What is RAC?
In fact, RAC is a simplified code of the third-party library Reactivecocoa, directly with Cocoapods added to the project can be, podfile file add pod ' Reactivecocoa ', and then terminal pod Install, header file reference:
#import <ReactiveCocoa/ReactiveCocoa.h>
Using RAC
1. Methods
The simplest use of RAC is to listen to events.
If you now have a button, if you want to add a click event method to the button, we will typically do this:
/// Add a Click event [Self.button addtarget:self Action: @selector (ButtonClick:) forcontrolevents:uicontroleventtouchupinside]; /// method Implementation -(void) ButtonClick: (UIButton *) sender{ NSLog (@ " click button " );}
But if you use RAC, you can do this:
[[Self.button Rac_signalforcontrolevents:uicontroleventtouchupinside] subscribenext:^ (ID x) { NSLog (@ " click button"); }];
Related reference: http://www.jianshu.com/p/ff79a5ae0353
Ios-rac start with the novice