无法转换 Swift 中类型错误的值

Cannot convert value of type error in Swift

我是 Swift 的新手,所以我正在学习如何从该页面制作计步器应用程序的教程:http://shrikar.com/ios-swift-development-step-counter-app-using-pedometer-data/

不过,那是不久前的事了,所以我一直在努力更新它,但进展并不顺利。我不断收到此错误:

Cannot convert value of type '(CMPedometerData?, NSError?) -> Void' to expected argument type 'CMPedometerHandler' (aka '(Optional<CMPedometerData>, Optional<Error>) -> ()')

到目前为止,这是我的代码:

if(CMPedometer.isStepCountingAvailable()){
        let fromDate = NSDate(timeIntervalSinceNow: -86400 * 7)
        self.pedoMeter.queryPedometerDataFromDate(fromDate as Date, toDate: NSDate() as Date) { (data : CMPedometerData?, error: NSError?) -> Void in
            DispatchQueue.main.async(){
                if(error == nil){
                    self.steps.text = "\(data.numberOfSteps)"
                }
            }
        }

        self.pedoMeter.startPedometerUpdatesFromDate(newDay) { (data: CMPedometerData?, error: NSError?) -> Void in
            DispatchQueue.main.async(){
                if(error == nil){
                    self.steps.text = "\(data.numberOfSteps)"
                }
            }
        }
    }

错误发生在以下行:

{ (data : CMPedometerData?, error: NSError?) -> Void in
            DispatchQueue.main.async(){

感谢任何帮助。

它期望 Error?,而您使用的是 NSError?。尝试

(data : CMPedometerData?, error: Error?) -> Void