Challenge - Does not work on all devices


#1

I implemented what I believed to be the correct code for the Challenge to Chapter 4 (displaying) the heading information.

I added two labels to the UI so that I could walk about outside to see if it changed.

Unfortunately the heading information did not display so I looked at this topic under the first edition:
http://forums.bignerdranch.com/viewtopic.php?f=46&t=289

My device is an iPhone 3G, on which the heading information does not work.

At least by looking at this topic I found out I implemented the correct code :smiley:

Nick
http://myfirstiphoneapp.co.uk


#2

From the documentation of CLLocationManager in iOS 4.3

“Some location services require the presence of specific hardware on the given device. For example, heading information is available only for devices that contain a hardware compass. This class defines several methods that you can use to determine which services are currently available.”

So running the code on the simulator won’t work.

The authors did stress that poking around in the Apple documentation is an essential skill. Then again, it’s probably a little hard on new developers. I didn’t get the results expected either and only found out the reason after Googling.


#3

I also bumped into this wall. I was trying it out on the simulator, which obviously didn’t work. I looked a bit around in the apple documentation, but didn’t get an answer before coming here. I know it’s an essential skill to use the documentation, but as being very new to this i couldn’t find it. After hooking up my own device though, it works.

Thanks for the post, now i can move on knowing i did the challenge right :slight_smile:

Best Regards
/JBJ
Follow me on - www.jbjprogramming.com


#4

Hi there

This is my code. According to the documentation, we should check if the device implements heading, so I added an if statement:

// Tell our manager to start updating its heading if the device supports it if ([CLLocationManager headingAvailable] == YES) [locationManager startUpdatingHeading];

According to the documentation, when a new heading is “available”, CLLocationManager will update the delegate with it. If the device doesn’t support heading, nothing will happen. So I just added this method:

-(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading { NSLog(@"%@", newHeading); }

Also, since I updated my only iPhone to the GM release of iOS5, but didn’t update my Xcode, I won’t be able to test it on a device till next week.
I didn’t get a heading update on the simulator.


#5

Found this in help section:

Some location services require the presence of specific hardware on the given device. For example, heading information is available only for devices that contain a hardware compass.

also:

Configuring Heading-Related Services

In iOS, a device with the appropriate hardware may also report heading information. When the value in the headingAvailable property is YES, you can use a location manager object to retrieve heading information. To begin the delivery of heading-related events, assign a delegate to the location manager object and call the location manager’s startUpdatingHeading method. If location updates are also enabled, the location manager returns both the true heading and magnetic heading values. If location updates are not enabled, the location manager returns only the magnetic heading value. These features are not available in Mac OS X.

No iphone, no heading i guess.


#6

[quote=“floyder”]Found this in help section:
To begin the delivery of heading-related events, assign a delegate to the location manager object and call the location manager’s startUpdatingHeading method. [/quote]

Hi there, I’m also at this point of the Whereami app. the heading available is = YES and the next line calls the startUpdatingHeading method but it never gets there. I’ve tried this on my simiulator ( ios 5) as well as my new iphone ( 5.0.1) but nothing happens ie it never gets into the method :

-(void)locationManager:(CLLocationManager *)manager
didUpdateHeading:(CLHeading *)newHeading
{
NSLog(@"%@", newHeading);
}

Many thanks !


#7

Problem solved ( not sure how) - the heading method is being called now on my iphone


#8

It would be nice if Apple provided an option in the iOS simulators to simulate heading information. I checked the Simulator’s menus and don’t see such an option, though. I’ll send this suggestion to Apple.