Start with iOS-RAC and start with iOS-RAC
What is RAC?
In fact, RAC is a third-party library ReactiveCocoa that simplifies code. You can directly use Cocoapods to add it to the project. Add the pod 'reactivecocoa 'to the podfile file, and then install the terminal pod. the header file references:
# Import <ReactiveCocoa/ReactiveCocoa. h>
Use RAC
1. Method
The simplest way to use RAC is to listen to events.
For example, if you want to add an event method to a button, we generally do this:
/// Add a click event [self. button addTarget: self action: @ selector (buttonClick :) forControlEvents: UIControlEventTouchUpInside]; // method implementation-(void) buttonClick :( UIButton *) sender {NSLog (@ "click button ");}
However, if RAC is used, you can:
[[Self. button rac_signalForControlEvents: UIControlEventTouchUpInside] subscribeNext: ^ (id x) {NSLog (@ "click button");}];
Reference: http://www.jianshu.com/p/ff79a5ae0353