I am developing an app which uses gps. i need a high accuracy so i used kCLLocationAccuracyBestForNavigation for the desiredAccuracy.
when i am running the app, the follwing method gets called as expected.
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
within this method i am checking if the accuracy is good enough with the follwing code segment:
if (newLocation.horizontalAccuracy <= locationManager.desiredAccuracy) {
...
}
but this if-block never gets active, as the newLocation.horizontalAccuracy is not going below 17.00 meters. When i was running this code on iPhone 3GS OS 3.1.2 everything was running fine. but since i upgraded to 4.0.1 it seems that there is a problem with the accuracy. It even doesn’t work with kCLLocationAccuracyNearestTenMeters which was also running smooth and stable on iOs 3.1.2.
do you have any hints for me whats going on and how i can solve my problem ?
The problem with your if block is that you are comparing
horizontalAccuracy, which is reported in meters, againstdesiredAccuracy, which is set as the constant valuekCLLocationAccuracyBestForNavigation. These constants aren’t defined in the documentation, but other constants are just enumerated. So kCLLocationAccuracyBestForNavigation may just be literally equal to 0. Your horizontalAccuracy would never be less than or equal to zero.You need to test your horizontal accuracy against a an actual number. The best horizontal Accuracy I’ve gotten is 5.0. So, you may want to change your if statement to
!(newLocation.horizontalAccuracy > 5.0).