iOS Developer Library

Developer

CoreMotion Framework Reference CMMotionActivity Class Reference

Options
Deployment Target:

On This Page
Language:

CMMotionActivity

Inherits From


Conforms To


Import Statement


Swift

import CoreMotion

Objective-C

@import CoreMotion;

Availability


Available in iOS 7.0 and later

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.

The motion-related properties of this class are not mutually exclusive. In other words, it is possible for more than one of the motion-related properties to contain the value YEStrue. For example, if the user was driving in a car and the car stopped at a red light, the update event associated with that change in motion would have both the automotive and stationary properties set to YEStrue. It is also possible for all of the properties to be set to NOfalse when the device is in motion but the movement does not correlate to walking, running, cycling or automotive travel.

You do not create instances of this class yourself. The CMMotionActivityManager object creates them and sends them to the handler block you registered. For more information about how to initiate the delivery of motion activity updates to your app, see CMMotionActivityManager Class Reference.

  • A Boolean indicating whether the device is stationary. (read-only)

    Declaration

    Swift

    var stationary: Bool { get }

    Objective-C

    @property(readonly, nonatomic) BOOL stationary

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 7.0 and later

  • walking walking Property

    A Boolean indicating whether the device is on a walking person. (read-only)

    Declaration

    Swift

    var walking: Bool { get }

    Objective-C

    @property(readonly, nonatomic) BOOL walking

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 7.0 and later

  • running running Property

    A Boolean indicating whether the device is on a running person. (read-only)

    Declaration

    Swift

    var running: Bool { get }

    Objective-C

    @property(readonly, nonatomic) BOOL running

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 7.0 and later

  • A Boolean indicating whether the device is in an automobile. (read-only)

    Declaration

    Swift

    var automotive: Bool { get }

    Objective-C

    @property(readonly, nonatomic) BOOL automotive

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 7.0 and later

  • cycling cycling Property

    A Boolean indicating whether the device is in an bicycle. (read-only)

    Declaration

    Swift

    var cycling: Bool { get }

    Objective-C

    @property(readonly, nonatomic) BOOL cycling

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 8.0 and later

  • unknown unknown Property

    A Boolean indicating whether the type of motion is unknown. (read-only)

    Declaration

    Swift

    var unknown: Bool { get }

    Objective-C

    @property(readonly, nonatomic) BOOL unknown

    Discussion

    This property is set to YEStrue when there is no way to estimate the current type of motion. For example, this property might be YEStrue if the device was turned on recently and not enough motion data had been gathered to determine the type of motion.

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 7.0 and later

  • startDate startDate Property

    The time at which the change in motion occurred. (read-only)

    Declaration

    Swift

    var startDate: NSDate! { get }

    Objective-C

    @property(readonly, nonatomic) NSDate *startDate

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 7.0 and later

  • The confidence in the assessment of the motion type. (read-only)

    Declaration

    Swift

    var confidence: CMMotionActivityConfidence { get }

    Objective-C

    @property(readonly, nonatomic) CMMotionActivityConfidence confidence

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 7.0 and later

  • The confidence that the motion data is accurate.

    Declaration

    Swift

    enum CMMotionActivityConfidence : Int { case Low case Medium case High }

    Objective-C

    typedef enum : NSInteger { CMMotionActivityConfidenceLow = 0, CMMotionActivityConfidenceMedium, CMMotionActivityConfidenceHigh }CMMotionActivityConfidence;

    Constants

    • Low

      CMMotionActivityConfidenceLow

      Confidence is low.

      Available in iOS 7.0 and later

    • Medium

      CMMotionActivityConfidenceMedium

      Confidence is good.

      Available in iOS 7.0 and later

    • High

      CMMotionActivityConfidenceHigh

      Confidence is high.

      Available in iOS 7.0 and later

    Import Statement

    Objective-C

    @import CoreMotion;

    Swift

    import CoreMotion

    Availability

    Available in iOS 7.0 and later