Class

CMAltimeter

An object that initiates the delivery of altitude-related changes.

Declaration

class CMAltimeter : NSObject

Overview

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.

After checking for the availability of altitude data, you start the delivery of events by calling the startRelativeAltitudeUpdates(to:withHandler:) method. Core Motion generates events at regular intervals (regardless of whether the data has changed) and delivers them to the block you specified at startup. When you no longer need the event data, call the stopRelativeAltitudeUpdates() method.

Core Motion delivers altimeter events only while your app is running, either in the foreground or background. If your app is suspended, event delivery stops temporarily. Event delivery resumes when your app returns to the foreground.

Topics

Determining Altitude Availability

class func isRelativeAltitudeAvailable() -> Bool

Returns a Boolean value indicating whether the current device supports generating data for relative altitude changes.

class func authorizationStatus() -> CMAuthorizationStatus

Returns a value indicating whether the app is authorized to retrieve altimeter data.

enum CMAuthorizationStatus

The authorization status for motion-related features.

Starting and Stopping Altitude Updates

func startRelativeAltitudeUpdates(to: OperationQueue, withHandler: CMAltitudeHandler)

Starts the delivery of altitude data to the specified handler block.

func stopRelativeAltitudeUpdates()

Stops the delivery of altitude data for this altimeter object

typealias CMAltitudeHandler

A block for receiving altitude data.

Relationships

Inherits From

Conforms To

See Also

Altitude

class CMAltitudeData

Data for a recorded change in altitude.