swift - --> (dash dash greater than) 运算符在 Swift 中是什么意思

标签 swift

我看GPUImage2的源码

    picture = PictureInput(image:UIImage(named:"WID-small.jpg")!)
    filter = SaturationAdjustment()
    picture --> filter --> renderView
    picture.processImage()

--> 是做什么的?

最佳答案

这是一个声明为将目标添加到源的运算符。

infix operator --> : AdditionPrecedence
//precedencegroup ProcessingOperationPrecedence {
//    associativity: left
////    higherThan: Multiplicative
//}
@discardableResult public func --><T:ImageConsumer>(source:ImageSource, destination:T) -> T {
    source.addTarget(destination)
    return destination
}

函数在pipeline.swift文件中声明

addTarget 函数也非常 self 描述。

public func addTarget(_ target:ImageConsumer, atTargetIndex:UInt? = nil) {
    if let targetIndex = atTargetIndex {
        target.setSource(self, atIndex:targetIndex)
        targets.append(target, indexAtTarget:targetIndex)
        transmitPreviousImage(to:target, atIndex:targetIndex)
    } else if let indexAtTarget = target.addSource(self) {
        targets.append(target, indexAtTarget:indexAtTarget)
        transmitPreviousImage(to:target, atIndex:indexAtTarget)
    } else {
        debugPrint("Warning: tried to add target beyond target's input capacity")
    }
}

编辑 正如其他人所说,运算符(operator)是该项目的自定义运算符(operator),截至 2018 年 3 月 29 日,该运算符(operator)并未内置在 swift 语言中

关于swift - --> (dash dash greater than) 运算符在 Swift 中是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42478881/

相关文章:

iphone - 更改 "sounder"的音频音高

swift - 扩展关联类型等于 Void 的自定义类型

ios - 在 Windows 机器上压缩后的预期标识符或 '('

methods - Swift 的 Superinit 问题

ios - 关于 sender.tag 按钮

ios - 无法使用正则表达式获取全名

ios - 正确的登录流程和 TabBar VC

ios - 尝试在 USerDefault 中保存图像时我做错了什么

swift - 创建 Swift 框架(重新访问)

ios - 可以创建 UIWindow 来掩盖推送通知的自动转场吗?