The type of block callback for handling accelerometer data.
SDKs
- iOS 4.0+
- macOS 10.15+
- Mac Catalyst 13.0+
- watchOS 2.0+
Framework
- Core Motion
Declaration
typealias CMAccelerometerHandler = (CMAccelerometer Data?, Error?) -> Void
Discussion
Blocks of type CMAccelerometer
are called when there is accelerometer data to process. You pass the block into start
as the second argument. Blocks of this type return no value but take two arguments:
accelerometer
Data An object that encapsulates a
CMAcceleration
structure with fields holding acceleration values for the three axes of movement.error
An error object representing an error encountered in providing accelerometer updates. If an error occurs, you should stop accelerometer updates and inform the user of the problem. If there is no error, this argument is
nil
. Core Motion errors are of theCMError
domain and theDomain CMError
type.