Here is what I did for the Silver Challenge in chapter 4. I thought I that the best place to check to see if the device supported headings was in the init method, so I called the location manager’s “headingAvailable” method. There is a depricated property in older versions of OS that held a BOOL value of either YES or NO to tell you if the device supported headings, but that has been replaced with a class method called the same name. My XCode warns me that I’m calling a depricated property, and I don’t know how to fix that. But, I know the method is working because the device does start updating headings.
Next, I use the “startUpdatingHeading” method to tell the device to update the headings when available. If heading information is not available, the method is never reached. Next, I implemented the optional “didUpdateHeading” method and just tell it to give me an update when there is a new heading.
Here is the output from my iPhone 4S when tested on the device: “May 28 09:02:22 unknown Whereami : The new heading is magneticHeading 131.06 trueHeading 132.44 accuracy 10.00 x -15.028 y -14.350 z -48.395 @ 2012-05-28 14:02:22 +0000.” There are HUNDREDS of lines on the phone’s log for every little change in heading.
Am I doing something wrong in terms of the “headingAvailable” method?