CMMotionActivity Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/CoreMotion.framework
Availability
Available in iOS 7.0 and later.
Declared in
CMMotionActivity.h

Overview

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 YES. 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 YES. It is also possible for all of the properties to be set to NO when the device is in motion but the movement does not correlate to walking, running, 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.

Tasks

Getting the Type of Motion

Getting Metadata for the Motion

Properties

automotive

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

@property(readonly, nonatomic) BOOL automotive;
Availability
  • Available in iOS 7.0 and later.
Declared In
CMMotionActivity.h

confidence

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

@property(readonly, nonatomic) CMMotionActivityConfidence confidence;
Availability
  • Available in iOS 7.0 and later.
Declared In
CMMotionActivity.h

running

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

@property(readonly, nonatomic) BOOL running;
Availability
  • Available in iOS 7.0 and later.
Declared In
CMMotionActivity.h

startDate

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

@property(readonly, nonatomic) NSDate *startDate;
Availability
  • Available in iOS 7.0 and later.
Declared In
CMMotionActivity.h

stationary

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

@property(readonly, nonatomic) BOOL stationary;
Availability
  • Available in iOS 7.0 and later.
Declared In
CMMotionActivity.h

unknown

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

@property(readonly, nonatomic) BOOL unknown;
Discussion

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

Availability
  • Available in iOS 7.0 and later.
Declared In
CMMotionActivity.h

walking

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

@property(readonly, nonatomic) BOOL walking;
Availability
  • Available in iOS 7.0 and later.
Declared In
CMMotionActivity.h

Constants

CMMotionActivityConfidence

The confidence that the motion data is accurate.

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

Confidence is low.

Available in iOS 7.0 and later.

Declared in CMMotionActivity.h.

CMMotionActivityConfidenceMedium

Confidence is good.

Available in iOS 7.0 and later.

Declared in CMMotionActivity.h.

CMMotionActivityConfidenceHigh

Confidence is high.

Available in iOS 7.0 and later.

Declared in CMMotionActivity.h.