Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Brandon Jonas
Brandon Jonas
13,387 Points

Problem with CLLocation: Longitude and Latitude registering as 0.000

There is an issue with my iOS application in finding the location in longitude and latitude where it is registering as longitude 0.000 and latitude 0.000 when trying to get the location.

self.locationManager = [[CLLocationManager alloc]init]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; self.locationManager.distanceFilter = 30; // Meters. [self.locationManager startUpdatingLocation];

I call these lines in my viewDidLoad method and I have implemented a didUpdateLocations method

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { self.location = locations.lastObject; }

For some reason this method is never being called. I have linked the delegate to my interface and have created properties for my CLLocationManager and CLLocation. I have tried running the code in the simulator and on an iPhone with the same result.

2 Answers

Alejandra H Bernal
PLUS
Alejandra H Bernal
Courses Plus Student 4,667 Points

I have the same problem, it works in Xcode 5, but locationManager:didUpdateLocations: is never called in Xcode 6. It also happens with the last project file that I downloaded from the last video of the Diary App.

Brandon Jonas
Brandon Jonas
13,387 Points

That was the conclusion I came to as well. It doesn't say anything about this method being depreciated in iOS 8, so I am not sure why it stopped working.

Thomas Nilsen
Thomas Nilsen
14,957 Points

Can you share the project through a dropbox link or something so I can have a look? :)