下載地址:https://github.com/ReactiveCocoa/ReactiveObjC
#import <ReactiveObjC/ReactiveObjC.h>
一坠宴、通知
//監(jiān)聽App離開了
__block RACDisposable *notf = [[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIApplicationWillResignActiveNotification object:nil] takeUntil:[self rac_willDeallocSignal]] subscribeNext:^(NSNotification * _Nullable x) {
//分享結(jié)果回調(diào),點(diǎn)擊就算分享成功
if (completion) {
completion(@"1",@"");//分享成功
}
[notf dispose];//銷毀通知
}];
二以躯、監(jiān)聽對象屬性變化(KVO)
[[_progressView rac_valuesForKeyPath:@"progress" observer:self] subscribeNext:^(id _Nullable x) {
weakself.walkProgressView.progressView.progress = [x floatValue];
}];
三、Button點(diǎn)擊事件
[[cancelButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
}];