Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Swift 3中键入别名方法?_Swift_Swift3_Type Alias - Fatal编程技术网

如何在Swift 3中键入别名方法?

如何在Swift 3中键入别名方法?,swift,swift3,type-alias,Swift,Swift3,Type Alias,我正在尝试将我的Swift 2+代码转换为Swift 3。我有一些typealias代码引用,我无法按照Swift 3语法要求修复这些引用 typealias UpdateProcessHandler = (_ value:Double) -> Void class StartUploadingProcess: Operation { ... fileprivate var updateHandler: UpdateProcessHandler! init(fi

我正在尝试将我的Swift 2+代码转换为Swift 3。我有一些
typealias
代码引用,我无法按照Swift 3语法要求修复这些引用

typealias UpdateProcessHandler = (_ value:Double) -> Void

class StartUploadingProcess: Operation
{
    ...
    fileprivate var updateHandler: UpdateProcessHandler!

    init(filePath: String, updateHandler:@escaping UpdateProcessHandler)
    {
        self.updateHandler = updateHandler
        ...
    }

    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?)
    {
        ...
        self.updateHandler(value: self.progress.fractionCompleted)
        ...
    }
}
当我试图调用方法
self.updateHandler
时,XCode报告编译器错误:
无法调用非函数类型“UpdateProcessHandler!”的值


我为什么要这样做,或者如何解决这个问题?

这是我的荣幸。函数签名中的下划线表示没有
值的标签
。函数签名中的下划线表示没有
值的标签。
self.updateHandler(self.progress.fractionCompleted)