小编gka*_*kas的帖子

ReactiveSwift:如何编写任务计划程序

我正在尝试创建一个调度程序来消耗一些数据。

调度程序必须能够:

  • 每次应手动消耗数据时发送一个事件
  • 每次数据应在上次消费后经过一段时间后自动消费时发送一个事件

我用一个模型模拟了手动消耗MutableProperty

 let consume = MutableProperty<Void>()
Run Code Online (Sandbox Code Playgroud)

我正在尝试用一个模型来模拟自动消耗SignalProducer

 let timer = SignalProducer<Void, NoError>
Run Code Online (Sandbox Code Playgroud)

我可以通过组合这两个生产者的最新值来第一次需要使用该数据,例如

SignalProducer.combineLatest(consume.producer, timer)
    .take(first: 1)
    .map() { _ in return () }
Run Code Online (Sandbox Code Playgroud)

这样,无论哪个先发生,生产者都会发送一个值,无论是手动消耗还是自动消耗。

我不知道我怎样才能永远做到这一点。

有人可以帮忙吗?

ios reactive-cocoa swift

3
推荐指数
1
解决办法
3212
查看次数

多个自定义行UITableView?

我一直在搜索很多,但没有发现任何与多个自定义行有关的内容,我需要为我的应用程序创建一个设置tableView,其中我需要从xib文件加载行,如:

ROW 1 = >> XIB 1.
ROW 2 = >> XIB 2.
ROW 3 = >> XIB 3.
ROW 4 = >> XIB 4.

我现在的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell=nil;
    //We use CellType1 xib for certain rows
    if(indexPath.row==0){
        static NSString *CellIdentifier = @"ACell";
        cell =(ACell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if(cell==nil){
            NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"ACell" owner:self options:nil];
            cell = (ACell *)[nib objectAtIndex:0];
        }
        //Custom cell with whatever
        //[cell.customLabelA setText:@"myText"]
    }
    //We use CellType2 xib for other rows …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview custom-cell ios

2
推荐指数
1
解决办法
5450
查看次数

标签 统计

ios ×2

custom-cell ×1

iphone ×1

reactive-cocoa ×1

swift ×1

uitableview ×1