startDeviceMotionUpdates(to:withHandler:)
Starts device-motion updates on an operation queue and using a specified block handler.
Declaration
func startDeviceMotionUpdates(to queue: OperationQueue, withHandler handler: @escaping CMDeviceMotionHandler)Parameters
- queue:
An operation queue provided by the caller. Because the processed events might arrive at a high rate, using the main operation queue is not recommended.
- handler:
A block that is invoked with each update to handle new device-motion data. The block must conform to the Cmdevicemotionhandler type.
Discussion
This method reports motion relative to the reference frame in the attitudeReferenceFrame property. You must call stopDeviceMotionUpdates() when you no longer want your app to process device-motion updates.