1
votes

I just updated xcode to 7.0 and my existing gyroscope code is now giving me an error. I have been playing with this for hours and I can't figure this out. How do I correct this?

    override func viewDidLoad() {

    if motionManager.gyroAvailable {

        motionManager.startGyroUpdates()
        motionManager.deviceMotionUpdateInterval = 0.2
        motionManager.startDeviceMotionUpdates()

        motionManager.gyroUpdateInterval = 0.2
        motionManager.startGyroUpdatesToQueue(NSOperationQueue.currentQueue()!) {
            [weak self] (gyroData: CMGyroData!, error: NSError!) in

            self!.outputRotationData(gyroData.rotationRate)
            if error != nil {
                print("\(error)")
            }

        }
    } else {
        print("gyro not avail")
    }

    super.viewDidLoad()
}

Error 1: Cannot convert value of type '(CMRotationRate, error: NSError.Type)' to expected argument type 'CMGyroHandler' (aka '(Optional, Optional) -> ()')

1

1 Answers

2
votes
motionManager.startGyroUpdatesToQueue(NSOperationQueue.mainQueue(), withHandler: { (gyroData, NSError) -> Void in
    self.outputRotationData(gyroData!.rotationRate)            
})