【问题标题】:RXSwift How to create wrapper for delegate method with return valueRXSwift 如何为具有返回值的委托方法创建包装器
【发布时间】:2016-01-27 14:50:25
【问题描述】:

我在 RXSwift 中有一个委托包装器

func tableView(tableView: UITableView,movedRowAtIndexPath sourceIndexPath: NSIndexPath,toIndexRowPath destinationRowIndexPath: NSIndexPath)    

它们看起来像

public var rx_itemRowMoved: ControlEvent<ItemMovedEvent> {
    let source: Observable<ItemMovedEvent> = rx_delegate.observe("tableView:movedRowAtIndexPath:toIndexRowPath:")
        .map { a in
            return ((a[1] as! NSIndexPath), (a[2] as! NSIndexPath))
    }

    return ControlEvent(events: source)
}

但我有带返回值的委托

 func selectionViewForTableView(tableView: UITableView,destinitionCell cell:UITableViewCell,toIndexRowPath destinationRowIndexPath: NSIndexPath) -> UIView

我如何为这个委托实现包装器?

【问题讨论】:

    标签: ios swift uitableview rx-swift


    【解决方案1】:

    没有办法做到这一点。您可以直接在您的委托所有者中实现此方法。您也可以参考RxTableViewReactiveArrayDataSourceCellFactory。它将方法更改为阻塞。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多