Framework

Core Motion

Receive and handle accelerometer events and other motion events.

Overview

The Core Motion framework lets your application receive motion data from device hardware and process that data. The framework supports accessing both raw and processed accelerometer data using Block object interfaces. For devices with a built-in gyroscope, you can retrieve the raw gyro data as well as processed data reflecting the attitude and rotation rates of the device. You can use both the accelerometer and gyro-based data for games or other apps that use motion as input or as a way to enhance the overall user experience.

Symbols

Classes

CMAccelerometerData

An instance of the CMAccelerometerData class represents an accelerometer event. It is a measurement of acceleration along the three spatial axes at a moment of time.

CMAltimeter

Use a CMAltimeter object to initiate the delivery of altitude-related data to your app. Altitude events reflect the change in the current altitude, not the absolute altitude. So a hiking app might use this object to track the user’s elevation gain over the course of a hike. Because altitude events may not be available on all devices, always call the isRelativeAltitudeAvailable() method before using this service.

CMAltitudeData

A CMAltitudeData object encapsulates information about relative changes in altitude. You do not create instances of this class directly. When you want to receive altimeter changes, create an instance of the CMAltimeter class and use that object to query for events or to start the delivery of events. The altimeter object creates new instances of this class at appropriate times and delivers them to the handler you specify.

CMAttitude

An instance of the CMAttitude class represents a measurement of the device’s attitude at a point in time. "Attitude” refers to the orientation of a body relative to a given frame of reference.

CMDeviceMotion

An instance of CMDeviceMotion encapsulates measurements of the attitude, rotation rate, and acceleration of a device.

CMGyroData

An instance of the CMGyroData class contains a single measurement of the device’s rotation rate.

CMLogItem

The CMLogItem class is a base class for Core Motion classes that handle specific types of motion events. Objects of this class represent a piece of time-tagged data that can be logged to a file.

CMMagnetometerData

Instances of the CMMagnetometerData class encapsulated measurements of the magnetic field made by the device’s magnetometer.

CMMotionActivity

The CMMotionActivity class contains the data for a single motion update event. On devices that support motion, you can use a CMMotionActivityManager object to request updates when the current type of motion changes. When a change occurs, the update information is packaged into a CMMotionActivity object and sent to your app.

CMMotionActivityManager

The CMMotionActivityManager class provides access to the motion data stored by a device. Motion data reflects whether the user is walking, running, in a vehicle, or stationary for periods of time. A navigation app might look for changes in the current type of motion and offer different directions for each. Using this class, you can ask for notifications when the current type of motion changes or you can gather past motion change data.

CMMotionManager

A CMMotionManager object is the gateway to the motion services provided by iOS. These services provide an app with accelerometer data, rotation-rate data, magnetometer data, and other device-motion data such as attitude. These types of data originate with a device’s accelerometers and (on some models) its magnetometer and gyroscope.

CMPedometer

Use a CMPedometer object to fetch pedestrian-related data. You use a pedometer object to retrieve step counts and other information about the distance traveled and the number of floors ascended or descended. The pedometer object manages a cache of historic data that you can query or you can ask for live updates as the data is processed.

CMPedometerData

A CMPedometerData object encapsulates information about the distance traveled by a user on foot. You do not create instances of this class yourself. Instead, you use a CMPedometer object to request pedometer data from the system. The data for each request is packaged into an instance of this class and delivered to the handlers you registered with the pedometer object.

CMPedometerEvent
CMRecordedAccelerometerData

A CMRecordedAccelerometerData object contains a single piece of accelerometer data that was recorded by the device. You do not create instances of this class directly. Instead, you use a CMSensorRecorder object to retrieve already recorded data from the system.

CMSensorDataList

A CMSensorDataList object lets you enumerate over the CMRecordedAccelerometerData objects recorded by the system. You do not create instances of this class directly. Instead, you receive one as the result of a query for accelerometer data from a CMSensorRecorder object.

CMSensorRecorder

A CMSensorRecorder object controls the gathering and retrieval of accelerometer data from a device. 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.

CMStepCounter

The CMStepCounter class provides access to the number of steps the user has taken with the device. Step information is gathered on devices with the appropriate built-in hardware and stored so that you can run queries to determine the user’s recent physical activity. You use this class to gather both current step data and any historical data.

Deprecated

See Also

Related Documentation