From the last paragraph of your question it seems that you are interested in conversion of arbitrary magnetic heading to true heading on current location of the user.
In this case you can assign an ivar (or property) called variation
and update regulary in didUpdateHeading:
.
//instantiated as ivars or properties:
NSDate *variationTimestamp;
double variation; //or CLLocationDirection
CLLocationManager *locationManager;
-(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
CLLocation *location = locationManager.location;
//check if location is valid - it has to be for variation data to be valid too
if ((newHeading.headingAccuracy > 0) && (location.horizontalAccuracy > 0))
{
variation = newHeading.trueHeading - newHeading.magneticHeading;
variationTimestamp = newHeading.timestamp;
}
}
Since magnetic variation if an f(location)
- it is the same for all magnetic headings on the same location - you can use this variation
for calculations with user input.
The obvious drawback is that you have to have fresh location/heading data. Note: besides enabling heading updates you have to also enable location updates.