Create a gist now

Instantly share code, notes, and snippets.

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