View Full Version : Core Location Services Problem

Apr 21, 2011, 07:25 PM
I am just trying out Core Location for fun and I am having some problems.
I am trying to get the latitude of where I am but it is not working. There is no error, the problem is that my latitude displays as 0. Here is my code:


NSString *lattitude = [[NSString alloc]initWithFormat:@"%g",location.coordinate.latitude];
[locationField setStringValue:lattitude];


In my header file the only property I have set is the location property. I set the property like this:

@property(readonly NS_NONATOMIC_IOSONLY)CLLocation *location;

Does anyone know why my latitude shows as 0? I am sure it is something simple I forgot.

Apr 21, 2011, 07:34 PM
Does anyone know why my latitude shows as 0?

Possibly because location is nil. Sending a message to nil results in 0. Where do you create a CLLocation and set your location property?

Apr 21, 2011, 08:28 PM
I did not, how do I?