b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

面向对象 c语言 ReactiveCocoa的学习内容,下面方法(6)

电脑杂谈  发布时间:2018-02-14 11:08:50  来源:网络整理

[subscriber sendNext:@"hello"];

[subscriber sendCompleted];

return [RACDisposable disposableWithBlock:^{

//RACDisposable 的 block

NSLog(@"====end");

}];

}];

}];

//只要执行 execute 就会执行上面的 command 的 block

//[command execute:@1] 这里会返回一个信号就是上面的 RACCommand 里面返回的那个 block

[[command execute:@1] subscribeNext:^(id _Nullable x) {

NSLog(@"%@",x);

}];

• 输出结果:

```

2018-02-06 11:27:53.451167<0800 RACtest[2441:151535] 1

2018-02-06 11:27:53.451340>0800 RACtest[2441:151535] ====1

2018-02-06 11:27:53.457199<0800 RACtest[2441:151535] ====2

2018-02-06 11:27:53.457458>0800 RACtest[2441:151535] hello

2018-02-06 11:27:53.457807+0800 RACtest[2441:151535] ====end

```

• RACCommand 中的 executionSignals 的block返回的还是信号,executionSignals 的 switchToLatest 表示最近一次发送的信号;executing 命令有没有完成,可以在 executing 的block中获取,executing有一个 skip 方法可以跳过第一次(一般时候我们跳过第一次),最后一次当我们使用完订阅者后必须发送一个 [subscriber sendCompleted] 。

• 下面是一个使用 RACCommand 的例子,判断状态的

```

RACCommand *command = [[RACCommand alloc] initWithSignalBlock:^RACSignal * _Nonnull(id _Nullable input) {

//command 的block

NSLog(@"%@",input);

NSLog(@"====1");

return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber> _Nonnull subscriber) {

//RACSignal 的 block

NSLog(@"====2");

[subscriber sendNext:@"hello"];


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-77250-6.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 申晨曦
      申晨曦

      我觉得根据这条新闻看我们应该鼓掌庆贺

    • 孟守
      孟守

      越往后对我们越有利

    • 刘玉霞
      刘玉霞

      小小百姓又要上哪里去买呢

    热点图片
    拼命载入中...