---
title: CMSensorRecorder
framework: coremotion
role: symbol
role_heading: Class
path: coremotion/cmsensorrecorder
---

# CMSensorRecorder

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

## Declaration

```swift
class CMSensorRecorder
```

## Mentioned in

Getting movement disorder symptom data

## Overview

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:) 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: important: To use this API, you must include the 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()](coremotion/cmsensorrecorder/isaccelerometerrecordingavailable().md)
- [authorizationStatus()](coremotion/cmsensorrecorder/authorizationstatus().md)
- [CMAuthorizationStatus](coremotion/cmauthorizationstatus.md)
- [isAuthorizedForRecording()](coremotion/cmsensorrecorder/isauthorizedforrecording().md)

### Recording Accelerometer Data

- [recordAccelerometer(forDuration:)](coremotion/cmsensorrecorder/recordaccelerometer(forduration:).md)

### Retrieving Past Accelerometer Data

- [accelerometerData(from:to:)](coremotion/cmsensorrecorder/accelerometerdata(from:to:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Accelerometers

- [Getting raw accelerometer events](coremotion/getting-raw-accelerometer-events.md)
- [CMAccelerometerData](coremotion/cmaccelerometerdata.md)
- [CMRecordedAccelerometerData](coremotion/cmrecordedaccelerometerdata.md)
- [CMSensorDataList](coremotion/cmsensordatalist.md)
