inVINCEable
inVINCEable

Reputation: 2206

How often does coreLocation Update

I'm using the CoreLocation Framework and im curious how often it updates, its really inaccurate and im debating on calling the method from an NSTimer to increase how often its used. My code is Below

in ViewDidLoad

//location update
CLController = [[CoreLocationController alloc] init];
CLController.delegate = self;
[CLController.locMgr startUpdatingLocation];

my void methods

- (void)locationUpdate:(CLLocation *)location {

    int speedInt = [location speed]*2.23693629;
    if(speedInt < 0){
        speedInt = 0;
    }
    speedLabel.text = [NSString stringWithFormat:@"%d", speedInt];
}

- (void)locationError:(NSError *)error {
    speedLabel.text = [error description];
}

Upvotes: 0

Views: 1075

Answers (3)

Kuo Ming Lin
Kuo Ming Lin

Reputation: 143

Follow your code sense, that you can add this :

CLController.locMgr.desiredAccuracy = kCLLocationAccuracyBest;
CLController.locMgr.distanceFilter  = 10.0f; //To set updating distance up with x meter when you leaved the scope.
[CLController.locMgr startUpdatingLocation];

Hope it can help you.

Upvotes: 0

stosha
stosha

Reputation: 2148

You can assign desiredAccuracy property of CLLocationManager to kCLLocationAccuracyBest:

- (void) viewDidLoad
{
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate= self;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [self.locationManager startUpdatingLocation];
} 

Hope this helps you out.

Upvotes: 2

Rob
Rob

Reputation: 438467

The frequency of updates is determined by a combination of desiredAccuracy and distanceFilter (and, obviously, how much the user is moving). A distanceFilter of kCLDistanceFilterNone and desiredAccuracy of kCLLocationAccuracyBest or kCLLocationAccuracyBestForNavigation will get you the most updates (but drain your battery the fastest).

Using a NSTimer will not achieve greater accuracy. Rely upon CLLocationManager to update with the desired frequency, with some sensitivity to a reasonable balance between the app's requirements and the user's desire to not drain his or her battery unnecessarily.

See the Starting the Standard Location Service section of the Location Awareness Programming Guide. Also see the Tips for Conserving Battery Power section in that guide.

Upvotes: 6

Related Questions