The gathering and retrieval of accelerometer data from a device.


@interface CMSensorRecorder : NSObject


Use a sensor recorder to initiate the gathering of accelerometer data. Later, use the sensor recorder to fetch the recorded data so that 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 recordAccelerometerForDuration: 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. Listing 1 shows how to record 20 minutes worth of accelerometer data.

Listing 1

Recording accelerometer data

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


Checking the Availability of Sensor Recording

+ isAccelerometerRecordingAvailable

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

+ authorizationStatus

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


The authorization status for motion-related features.

+ isAuthorizedForRecording

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


Recording Accelerometer Data

- recordAccelerometerForDuration:

Begins recording accelerometer data for the specified period of time.

Retrieving Past Accelerometer Data

- accelerometerDataFromDate:toDate:

Retrieves the accelerometer data collected between the specified dates.

- accelerometerDataSince:

Retrieves the accelerometer data for entries in the same batch.


Inherits From

See Also


Getting Raw Accelerometer Events

Retrieve data from the onboard accelerometers.


A data sample from the device's three accelerometers.


A single piece of accelerometer data that was recorded by the device.


A list of the accelerometer data recorded by the system.