使用多个CLLocationManager实例是否会降低性能? [英] Is there any performance penalty for using multiple CLLocationManager instances

查看:82
本文介绍了使用多个CLLocationManager实例是否会降低性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中至少有两个控制器,当前使用它们自己的CLLocationManager实例。不过,我很好奇,如果使用多个实例实际上会给手机带来任何额外负担-除了不同实例的额外内存之外。

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.

iPhone会多次对GPS硬件执行ping操作,还是会使用某种调度方式将硬件抽象出来并转发给所有侦听器?我将要编写自己的抽象层来处理多个观察者,但想检查是否有任何知识表明不需要这样做。

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.

推荐答案

我会说不,这不会造成问题或性能下降。在一个应用程序中拥有多个CLLocationManager实例的成本并不比在后台使用CLLocationManagers拥有多个应用程序的成本更高。操作系统根据所有CLLocationManager的组合请求将GPS /蜂窝无线电配置为最低功耗。

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.

请确保在您的应用程序停止所有CLLocationManager实例上的位置更新不再需要它(即:在applicationWillResignActive:中),因此可以关闭GPS硬件以节省电池。

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.

这篇关于使用多个CLLocationManager实例是否会降低性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆