iOS CoreMotion - Calculating Height Difference
<p>Is it possible to calculate the difference in height when an iPhone moves using the data from CoreMotion?</p>

<p>For example, the initial position of the iPhone is saved, then the iPhone is moved which results in a new position. I am interested in detecting if the height of the iPhone moved from its initial position. I don't need absolute units, just a relative value indicating what percentage the height has changed from its original height.</p>

<pre><code>let manager = CMMotionManager()

// Save initial attitude
var initialAttitude = manager.deviceMotion.attitude

if manager.deviceMotionAvailable {
manager.startDeviceMotionUpdatesToQueue(NSOperationQueue.mainQueue()) {
    [weak self] (data: CMDeviceMotion!, error: NSError!) in

    // Get the difference between the initial and new attitude
    data.attitude.multiplyByInverseOfAttitude(initialAttitude)

    // Is there a way to calculate the relative change in height?

    }
}
</code></pre>