<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMotion",
  "identifier" : "/documentation/CoreMotion/CMSensorRecorder",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Motion"
    ],
    "preciseIdentifier" : "c:objc(cs)CMSensorRecorder"
  },
  "title" : "CMSensorRecorder"
}
-->

# CMSensorRecorder

An object that gathers and retrieves accelerometer data from a device.

```
class CMSensorRecorder
```

## Overview

Use a sensor recorder to initiate the gathering of accelerometer data. Later, use the sensor recorder to fetch the recorded data so you can analyze it. You might use the recorded data to assess specific types of motion and incorporate the results into your app.

To use a sensor recorder, create an instance of this class and call the [`recordAccelerometer(forDuration:)`](/documentation/CoreMotion/CMSensorRecorder/recordAccelerometer(forDuration:)) method to begin recording data. You do not need to stop the recording process explicitly. The system stops recording automatically when the specified time expires and no other apps extend the recording time. The following example shows how to record 20 minutes worth of accelerometer data:

```objc
if ([CMSensorRecorder isAccelerometerRecordingAvailable]) {
   CMSensorRecorder* recorder = [[CMSensorRecorder alloc] init];
   [recorder recordAccelerometerForDuration:(20 * 60)]; // Record for 20 minutes
}
```

> Important:
> To use this API, you must include the <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/NSMotionUsageDescription> key in your app’s `Info.plist` file and provide a usage description string for this key. The usage description appears in the prompt that the user must accept the first time the system asks the user to access motion data for your app. If you don’t include a usage description string, your app crashes when you call this API.

## Topics

### Checking the Availability of Sensor Recording

[`+  isAccelerometerRecordingAvailable`](/documentation/CoreMotion/CMSensorRecorder/isAccelerometerRecordingAvailable())

Returns a Boolean value indicating whether accelerometer recording is supported on the current device.

[`+  authorizationStatus`](/documentation/CoreMotion/CMSensorRecorder/authorizationStatus())

Returns a value indicating whether the app is authorized to record sensor data.

[`CMAuthorizationStatus`](/documentation/CoreMotion/CMAuthorizationStatus)

The authorization status for motion-related features.

[`+  isAuthorizedForRecording`](/documentation/CoreMotion/CMSensorRecorder/isAuthorizedForRecording())

Returns a Boolean value indicating whether the app is authorized to record sensor data.

### Recording Accelerometer Data

[`-  recordAccelerometerForDuration:`](/documentation/CoreMotion/CMSensorRecorder/recordAccelerometer(forDuration:))

Begins recording accelerometer data for the specified period of time.

### Retrieving Past Accelerometer Data

[`-  accelerometerDataFromDate:toDate:`](/documentation/CoreMotion/CMSensorRecorder/accelerometerData(from:to:))

Retrieves the accelerometer data collected between the specified dates.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)