<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMotion",
  "identifier" : "/documentation/CoreMotion/CMAccelerometerHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "Core Motion"
    ],
    "preciseIdentifier" : "c:@T@CMAccelerometerHandler"
  },
  "title" : "CMAccelerometerHandler"
}
-->

# CMAccelerometerHandler

The type of block callback for handling accelerometer data.

```
typealias CMAccelerometerHandler = (CMAccelerometerData?, (any Error)?) -> Void
```

## Discussion

Blocks of type `CMAccelerometerHandler` are called when there is accelerometer data to process. You pass the block into [`startAccelerometerUpdates(to:withHandler:)`](/documentation/CoreMotion/CMMotionManager/startAccelerometerUpdates(to:withHandler:)) as the second argument. Blocks of this type return no value but take two arguments:

- `accelerometerData`: An object that encapsulates a [`CMAcceleration`](/documentation/CoreMotion/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 the [`CMErrorDomain`](/documentation/CoreMotion/CMErrorDomain) domain and the [`CMError`](/documentation/CoreMotion/CMError) type.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)