当需要在多个网络请求完成之后才进行更新UI或者类似的事情的时候,可以用rac_liftSelector
-(void)requestData
{
//网络请求1
RACSignal *signal1 = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
NSLog(@"网络请求1");
[subscriber sendNext:@"网络请求1"];
return nil;
}];
//网络请求2
RACSignal *signal2 = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
NSLog(@"网络请求2");
[subscriber sendNext:@"网络请求2"];
return nil;
}];
//网络请求3
RACSignal *signal3 = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
NSLog(@"网络请求3");
[subscriber sendNext:@"网络请求3"];
return nil;
}];
[self rac_liftSelector:@selector(dealDataWithData1:data2:data3) signal1,signal2,signal3, nil];
}
-(void)dealDataWithData1:(id)data1 data2:(id)data2 data3:(id)data3
{
//三个网络请求结束后在这里处理数据
}
复制代码