I have a problem with access to CMDeviceMotion data. I have everything what is needed included, but my startDeviceMotionUpdates function seems to be passed over (I think that something's wrong with handler). Here is my code:
let manager = CMMotionManager()
if manager.isDeviceMotionAvailable {
manager.startDeviceMotionUpdates()
manager.deviceMotionUpdateInterval = 0.1
manager.startDeviceMotionUpdates(to: OperationQueue.current!, withHandler: {
(data, error) -> Void in
self.digit.text = String (describing: data!.gravity.z)
self.digit2.text = String (describing: data!.gravity.y)
self.digit3.text = String (describing: data!.gravity.z)
})
digit, digit2 and digit3 are edit text fields, where I want my gravity data written into. Everything is tested on iPhone 6 - deviceMotion is aviable and active. I managed to access data without startMotionUpdates function, but i got only NIL value. Any idea what is wrong? Thanks!