Contents

startDeviceMotionUpdates(using:to:withHandler:)

Starts device-motion updates on an operation queue and using a specified reference frame and block handler.

Declaration

func startDeviceMotionUpdates(using referenceFrame: CMAttitudeReferenceFrame, to queue: OperationQueue, withHandler handler: @escaping  CMDeviceMotionHandler)

Parameters

  • referenceFrame:

    A constant identifying the reference frame to use for device-motion updates. It’s your responsibility to specify a reference frame that’s available on the current device. Call Availableattitudereferenceframes() to determine which reference frames are currently available.

  • 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

You must call stopDeviceMotionUpdates() when you no longer want your app to process device-motion updates.

See Also

Managing Device Motion Updates