Rahul Vyas
Rahul Vyas

Reputation: 28740

how to get desired Accuracy from core location in simulator?

i want to check the desired accuracy in simulator but i never get it within didupdatetolocation method.I know that in simulator delegate method is called only once.Does someone knows how to get desired accuracy in simulator.Here is my code to get desired accuracy.

// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
    if (locationAge > 5.0)
    {
        self.DeviceOldLocation=newLocation;
        return;
    }
    LatitudeData = [[[[NSString alloc]  initWithFormat:@"%f",newLocation.coordinate.latitude] retain]autorelease];
    LongitudeData =[[[[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.longitude] retain]autorelease];

    if (newLocation.horizontalAccuracy < 0)
        return;

    if (bestEffortAtLocation == nil || bestEffortAtLocation.horizontalAccuracy < newLocation.horizontalAccuracy)
    {
        // store the location as the "best effort"
        self.bestEffortAtLocation = newLocation;
        [self insertNewLocationInDataBase];
        if (newLocation.horizontalAccuracy <= Accuracy)
        {
            self.VeryAccuratelocation=newLocation;
            BestLocationAcquired=YES;
            [self insertNewLocationInDataBase];
            [self stopUpdatingLocation];                
            UIAlertView *BestLocation=[[UIAlertView alloc] initWithTitle:@"Best Location" message:@"best location found" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
            [BestLocation show];
            [BestLocation release];
        }
    }
}

Upvotes: 2

Views: 1764

Answers (1)

Vladimir
Vladimir

Reputation: 170849

On simulator location manager always returns the same location with the same accuracy. So you should either adjust your accuracy threshold when targeting simulator or just test location service on real device.

#if TARGET_IPHONE_SIMULATOR
   double Accuracy = 100;
#else
  double Accuracy = 5;
#endif

Upvotes: 3

Related Questions