使用多个CLLocationManager实例是否会降低性能?

编程入门 行业动态 更新时间:2024-10-28 19:23:54
本文介绍了使用多个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实例是否会降低性能?

本文发布于:2023-11-12 00:40:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580017.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   是否会   实例   性能   CLLocationManager

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!