From the course: Advanced iOS App Development: MapKit & Core Location

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use headings

Use headings - iOS Tutorial

From the course: Advanced iOS App Development: MapKit & Core Location

Start my 1-month free trial

Use headings

- [Instructor] While you just found heading data from location data, you may not want to use location data to get a heading. As with the stationary point in Apple's parking lot, you can't get a heading without moving. Often, you'll just want heading data from the magnetometer. You can get raw magnetometer data in the Core Motion framework, and if you are interested, take a look at the Core Motion course. With a few position checks, Core Location can stabilize magnetometer data to make a pretty good compass for many applications. You'll find that setting up heading is the same as setting up position. I'll make a property in my view controller class called heading set and set it to 0.0, or due north. Now go to enable, location services, and add another if clause. Check if there's a magnetometer. If CLLocation manager heading available. If there is, I'm going to start updating heading, very much like I just did with positions. If I have no magnetometer, I'm going to print that the…

Contents