5

I've been trying to find any way to optimize the performance of my location-based iPhone application and have seen some people mention that you can force location updates by starting and stopping your CLLocationManager. I need the best accuracy I can get, and the user in my case would probably like to see updates every few seconds (say, 10 seconds) as they walk around. I've set the filters accordingly, but I notice that sometimes I don't get any updates on the device for quite some time.

I'm testing the following approach, which forces an update when a fixed time interval passes (I'm using 20 seconds). My gut tells me this really won't help me provide more accurate updates to the user, and that just leaving CLLocationManager running all the time is probably the best approach.

- (void)forceLocationUpdate {
    [[LocationManager locationManager] stopUpdates];
    [[LocationManager locationManager] startUpdates];
    [self performSelector:@selector(forceLocationUpdate) withObject:nil afterDelay:20.0];
}

My question is- does forcing updates from CLLocationManager actually improve core location performance? Does it hurt performance? If I'm outside in an open field with good GPS reception, will this help then? Does anyone have experience trying this?

Thanks in advance, Steve

Steve N
  • 2,667
  • 3
  • 30
  • 37
  • When setting up your CLLocationManager, you should set your `desiredAccuracy` criterion to `kCLLocationAccuracyBestForNavigation', available in iOS 4+. Then, let the OS optimize. – Nate May 23 '12 at 03:33

2 Answers2

0

Chances are if you have your desired accuracy and distance filter set correctly, then you aren't getting any updates because your user or test hasn't moved enough to trigger an update. Like the comment from @Nate said, if you set it to best or bestForNav, you have a better chance of getting more updates.

The real reason for shutting down your location manager is really to conserve battery. Most users that are using the device for GPS and nav know to keep it plugged in. If you aren't using location for something like that, you are better off getting your location and shutting it down to save battery until you need another location update. This can be done via timers or blocks. The main thing is to think about how you can operate and save as much battery as possible.

Bill Burgess
  • 14,054
  • 6
  • 49
  • 86
0

I'm also trying to optimise a 'near me' feature in an app - I found the following SO post info useful: link text

Community
  • 1
  • 1
petert
  • 6,672
  • 3
  • 38
  • 46