Class

CMPedometer

An object for fetching the system-generated live walking data.

Overview

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.

To use a pedometer object, create an instance of this class and call the appropriate methods. Use the queryPedometerData(from:to:withHandler:) method to retrieve data that has already been gathered. To get live updates, use the startUpdates(from:withHandler:) method to start the delivery of events to the handler you provide.

Topics

Determining Pedometer Availability

class func isStepCountingAvailable()

Returns a Boolean value indicating whether step counting is available on the current device.

class func isDistanceAvailable()

Returns a Boolean value indicating whether distance estimation is available on the current device.

class func isFloorCountingAvailable()

Returns a Boolean value indicating whether floor counting is available on the current device.

class func isPaceAvailable()

Returns a Boolean value indicating whether pace information is available on the current device.

class func isCadenceAvailable()

Returns a Boolean value indicating whether cadence information is available on the current device.

class func isPedometerEventTrackingAvailable()

Returns a Boolean value indicating whether pedometer events are available on the current device.

Generating Live Pedometer Data

func startUpdates(from: Date, withHandler: CMPedometerHandler)

Starts the delivery of recent pedestrian-related data to your app.

func stopUpdates()

Stops the delivery of recent pedestrian data updates to your app.

func startEventUpdates(handler: CMPedometerEventHandler)

Starts the delivery of pedometer events to your app.

func stopEventUpdates()

Stops the delivery of pedometer events to your app.

Fetching Historical Pedometer Data

func queryPedometerData(from: Date, to: Date, withHandler: CMPedometerHandler)

Retrieves the data between the specified start and end dates.

Constants

typealias CMPedometerHandler

A block for processing pedometer-related data.

typealias CMPedometerEventHandler

A block for processing pedometer events.

Relationships

Inherits From

Conforms To

See Also

Pedometer

class CMPedometerData

Information about the distance traveled by a user on foot.

class CMPedometerEvent

A change in the user's pedestrian activity.

class CMStepCounter

The number of steps the user has taken with the device.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software