title: Convert user entered true azimuth to magnetic azimuth
body: <p>I was wondering if there is a way to use <code>CLHeading</code> or <code>CLLocationDirection</code> to convert between true and magnetic azimuth for a USER entered value.</p>
  
  <p>In a normal scenario with plenty of examples on SO, we can use <code>didUpdateHeading:(CLocation) newHeading</code> with <code>newHeading.magneticHeading</code> or <code>trueHeading</code> to get those values when we want the device bearing/heading. Both <code>trueHeading</code> and <code>magneticHeading</code> are read only properties.
  However what I need is to provide a user entered true azimuth to <code>CLocation</code> or something else and return the magnetic value corresponding to the input.</p>
  
  <p>One way to do that is to get the updated magnetic field model of the earth from NOAA (or other sources) and write code to do this calculation based on the user location. However this has many drawbacks and requires constant updates to the model array in the app code since the model changes all the time. Using any built-in model would be great... </p>
  
  <p><strong>UPDATE (More Information to understand declination):</strong></p>
  
  <p>I tested the declination for the DC area and it correctly returned -10.7 degrees with the simple function in the answer by @rokjarc shown below. For reference on the  declination in the US, please see the following map (Image Source - NOAA):
  <img src="https://i.stack.imgur.com/8Y41N.jpg" alt="enter image description here"></p>
  
  <p>Later I will be deploying this on a friend's device in Houston, TX area where the declination is 2 degrees to further confirm.</p>
  
  <p>For those who wonder, when you use Apple's MapKit, the map is always oriented so that true north is situated at the top of the map -- source --
  (<a href="http://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/" rel="nofollow noreferrer">http://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/</a>)
  With the above information, you should always use true heading and NOT magnetic if displaying a POI with a bearing or azimuth relative to a location like what I was trying to achieve...</p>
  
  <p><strong>NOTE:</strong> Declination changes all the time (you may have heard of pole shift). If you test this in 2016 for example, DC may have a declination of -5 or -20 etc instead of the current -10. When using this method to calculate the declination you do not have to worry about changes in declination over time since the compass (I believe) will sense the magnetic field of the earth and return the correct <code>heading.magneticHeading</code></p>