Class

CMAltimeter

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

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()

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

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

Constants

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.