Unexpected number printed for CLLocation.coordinate.latitude
-
19-09-2019 - |
Question
I have an NSLog statement in my -didUpdateToLocation
method which prints the latitude of my location as expected:
NSLog(@"%g", newLocation.coordinate.latitude);
prints 37.3317
In the same method, i assign newLocation
to a CLLocation instance variable for use elsewhere.
self.selectedLocation = newLocation;
But when i NSLog this using %g
, i get this value -1.96638e-202
NSLog(@"%g", self.selectedLocation.coordinate.latitude);
What i have done wrong?
Thanks
Solution
in the .h file, what do you have for the property?
That is, you have a line like:
@property (copy)CLLocation* newLocation;
what is in the parenthesis?
OTHER TIPS
Are you testing this in the simulator? If you are it will always return the latitude as "37.33" and longitude as "-122.0" or near around which is the location of Cupertino, California, USA(The apple headquarters).
So if this is not the case show us some your code snippet.
Hope I helped you.
Thanks,
Madhup