Skip to content

Instantly share code, notes, and snippets.

Last active June 25, 2018 23:56
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Retrieving data for relative altitude and air pressure with CMAltimeter
// AltitudeViewController.swift
// Altitudes
// Created by Taylor Franklin on 10/22/14.
import UIKit
import CoreMotion
class AltitudeViewController: UIViewController {
@IBOutlet weak var altitudeLabel: UILabel!
let altimeter = CMAltimeter()
override func viewDidLoad() {
// Do any additional setup after loading the view, typically from a nib.
override func didReceiveMemoryWarning() {
// Dispose of any resources that can be recreated.
@IBAction func start(sender: AnyObject) {
if CMAltimeter.isRelativeAltitudeAvailable() {
altimeter.startRelativeAltitudeUpdatesToQueue(NSOperationQueue.mainQueue(), withHandler: { data, error in
if (error == nil) {
println("Relative Altitude: \(data.relativeAltitude)")
println("Pressure: \(data.pressure)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment