开发者

Is there any performance penalty for using multiple CLLocationManager instances

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 GP开发者_Python百科S 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜