iOS开发ReactiveObjC基础用法

下载地址:https://github.com/ReactiveCocoa/ReactiveObjC

#import <ReactiveObjC/ReactiveObjC.h>

一、通知

//监听App离开了
    __block RACDisposable *notf = [[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIApplicationWillResignActiveNotification object:nil] takeUntil:[self rac_willDeallocSignal]] subscribeNext:^(NSNotification * _Nullable x) {
        //分享结果回调,点击就算分享成功
        if (completion) {
            completion(@"1",@"");//分享成功
        }
        [notf dispose];//销毁通知
    }];

二、监听对象属性变化(KVO)

[[_progressView rac_valuesForKeyPath:@"progress" observer:self] subscribeNext:^(id  _Nullable x) {
            weakself.walkProgressView.progressView.progress = [x floatValue];
        }];

三、Button点击事件

[[cancelButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        
    }];
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。