代替代理:
1.RACSubject好处是可以传参 2.rac_signalForSelector好处是使用简单,不能传参;
rac_signalForSelector会监听一个函数调用了某个方法;

2.KVO


3.监听按钮的点击事件
[[self.btn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
NSLog(@"按钮发生了点击");
}];
4.代替通知
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIKeyboardWillShowNotification object:nil] subscribeNext:^(NSNotification * _Nullable x) {
NSLog(@"键盘升起");
}];
5.监听文本:
[self.tf.rac_textSignal subscribeNext:^(NSString * _Nullable x) {
NSLog(@"%@",x);
}];
6.处理多个请求,都返回结果的时候,统一处理;
rac_liftSelector在接收到多个信号后才会调用指定方法

网友评论