views:

111

answers:

1

Hey,

I'm having a hard time figuring out what I'm doing wrong. I want do read the direction my iPhone is facing to. Here's my code:

self.man = [[CLLocationManager alloc] init] ;
self.man.delegate = self; 
self.man.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
self.man.headingFilter = kCLHeadingFilterNone;
if([self.man headingAvailable]) {
NSLog(@"it works"); 
}
self.man.headingOrientation
[self.man startUpdatingLocation];

man is the Locationmanger. I read the location information in the delegate method and it says:

Location: <+51.49300130, +7.40472897> +/- 80.00m (speed -1.00 mps / course -1.00) @ 2010-09-02 16:53:51 +0200

Anyway, I don't know why it is -1 all the time - in my opinion it shouldn't be. I also do the check, whether detecting the heading is available.

Can anyone tell me where I am wrong?

+1  A: 

You need to call startUpdatingHeading to get compass information. See the documentation of CLLocationManager for more.

Tom Irving
thank you. i must have read an old tutorial. i should stop doing that.
Icky
No problem. Remember when in doubt, the documentation has everything you need :)
Tom Irving