我正在尝试将我的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报告编译器错误:Cannot call value of non-function type 'UpdateProcessHandler!'
为什么我有这个或如何解决这个问题?
答案 0 :(得分:2)
self.updateHandler(self.progress.fractionCompleted)