Starts accelerometer updates on an operation queue and with a specified handler.
SDKs
- iOS 4.0+
- Mac Catalyst 13.0+
- watchOS 2.0+
Framework
- Core Motion
Declaration
func startAccelerometerUpdates(to queue: Operation Queue, withHandler handler: @escaping CMAccelerometer Handler)
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 accelerometer data. The block must conform to the
CMAccelerometer
type.Handler
Discussion
You must call stop
when you no longer want your app to process accelerometer updates.