Reputation: 1
physicsWorld.gravity = CGVector(dx: 0, dy: -2)
physicsWorld.contactDelegate = self
motionManager.accelerometerUpdateInterval = 0.2
motionManager.startAccelerometerUpdatesToQueue(OperationQueue.currentQueue!) { (data:CMAccelerometerData?, error:NSError?) -> Void in
if let accelerometerData = data {
let acceleration = accelerometerData.acceleration
self.xAcceleration = (CGFloat(acceleration.x) * 0.75 + (self.xAcceleration * 0.25))
}
}
I don't know how to fix it, when I just click 'fix-it' it doesn't work
Upvotes: 0
Views: 58
Reputation: 6173
I think you're tricked by XCode, that bothers me as well (The "Fix-it" actually didn't fix it).
In your case, you're missing the to:
and withHandler:
Following are working code with Swift3.0.2
and XCode 8.2.1
under iOS 10
motionManager.startAccelerometerUpdates(
to: OperationQueue.main ,
withHandler:{ (data : CMAccelerometerData?, error : Error?) in
if let accelerometerData = data {
let acceleration = accelerometerData.acceleration
self.xAcceleration = (CGFloat(acceleration.x) * 0.75 + (self.xAcceleration * 0.25))
}
})
Upvotes: 1