iOS Developer Library

Developer

CoreMotion Framework Reference CMAccelerometerData Class Reference

Options
Deployment Target:

On This Page
Language:

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.

An application accesses CMAccelerometerData objects through the block handler specified as the last parameter of the startAccelerometerUpdatesToQueue:withHandler: method and through the accelerometerData property, both declared by the CMMotionManager class. The superclass of CMAccelerometerData, CMLogItem, defines a timestamp property that records when the acceleration measurement was taken.

Inheritance


Import Statement


Swift

import CoreMotion

Objective-C

@import CoreMotion;

Availability


Available in iOS 4.0 and later.
  • The acceleration measured by the accelerometer. (read-only)

    Declaration

    Swift

    var acceleration: CMAcceleration { get }

    Objective-C

    @property(readonly, nonatomic) CMAcceleration acceleration

    Discussion

    The description of the CMAcceleration structure type describes the fields used for measuring acceleration.

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 4.0 and later.

Data Types

  • The type of a structure containing 3-axis acceleration values.

    Declaration

    Swift

    struct CMAcceleration { var x: Double var y: Double var z: Double }

    Objective-C

    typedef struct { double x; double y; double z; } CMAcceleration;

    Discussion

    A G is a unit of gravitation force equal to that exerted by the earth’s gravitational field (9.81 m s−2).

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 4.0 and later.