Swift 2 to Swift 3.0 motionManager

后端 未结 2 1457
渐次进展
渐次进展 2021-01-26 23:30

I am converting an app from swift 2 to swift 3 and I\'m trying to use the CMMotionManager, but it gives me this error when I try to call the .startAccelerometerUpdates() functio

2条回答
  •  野性不改
    2021-01-26 23:56

    The cryptic error message boils down to this: in Swift 3 NSError is bridged to Error instead. Write your code like this and the problem should go away:

    motionManager.startAccelerometerUpdates(to: OperationQueue.main) { [weak self] (data: CMAccelerometerData?, error: Error?) in
    

提交回复
热议问题