I use this code to get the longitude and latitude.
(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
NSLog(@"%f",newLocation.coordinate.latitude);
self.location = newLocation;
}
But the longitude and latitude which i got has the excursion with the actual geographical position. How to solve this problem?
You should be testing the accuracy of the CLLocation object that is returned, and making sure it meets your location accuracy criteria.
Also, the
locationManager:didUpdateToLocation:fromLocation:method has been deprecated in iOS6 so you should uselocationManager:didUpdateLocations:if you’re targetting iOS6+.