In this tutorial we will have a look at how to set up the magnetometer using the Core Motion framework. Just like enabling the accelerometer or gyroscope, enabling the magnetometer is also extremely simple to do.
The magnetometer is used to provide measurements of the earths magnetic field relative to the device. You can use the magnetometer to derive the heading, but to do so you would need input from other sensors to help with the calculations. If you are more interested in using the compass, then Apple does cater for that with the CLHeading class which we will look at in another tutorial.
We will begin with a single view application, and work in ViewController.swift. [Read more…]