views:

70

answers:

1

I have at least two controllers in my app that currently use their own CLLocationManager instance. I'm curious however if using multiple instances actually imposes any additional burden on the phone - beyond the additional memory for the different instances.

Will the iPhone ping the GPS hardware multiple times, or does it use some sort of dispatch such that the hardware is abstracted and just forwarded to all listeners? I was about to write my own abstraction layer to handle multiple observers but wanted to check if there was any knowledge out there to suggest it's not necessary.

A: 

I would say no, it would not be a problem or performance penalty. Having multiple instances of CLLocationManager in one app is no more costly than having multiple apps in the background all with CLLocationManagers. The OS configures the GPS/cell radios for minimum power use based on the combined requests of all the CLLocationManagers.

Be sure to stop location updates on all CLLocationManager instances when your app doesn't need it anymore (ie: in applicationWillResignActive:) so the GPS h/w can be turned off to save battery.

progrmr
"The OS configures the GPS/cell radios for minimum power use based on the combined requests of all the CLLocationManagers." Where is it written on the docs?
vfn
"Be sure to stop location updates on all CLLocationManager instances when your app doesn't need it anymore (ie: in applicationWillResignActive:) so the GPS can be turned off to save battery." The GPS will only continue active if you configure your app to receive updates when in background (only iOS4), otherwise the GPS will be turned off if no other app is asking for location. The good practice is to turn to stop the location manager as soon as you don't need GPS info, and not only on applicationWillResignActive:. Change the "i.e." to "e.g.", and you will fix it.
vfn
@progrmr: any actual references or real world examples to back this up or is this just your understanding?
Paul Alexander
@Paul: I have a location based app in the itunes store and did extensive testing and measurements before releasing it.
progrmr