当我单击应用程序中的注销按钮时,如何释放所有 CLLocationManager 实例?
我的应用程序是一个标签栏。我有 4 个视图,每个视图中都有 CLLocationManager 实例。在每个视图中我都有注销按钮。我想在单击注销时释放所有 CLLocationManager 实例。是否可以?提前致谢。
My app is a tab bar. i have 4 views and i have CLLocationManager instance in every view. In every view i have logout button. I want to release all CLLocationManager instances when i click on logout. Is it possible? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您只需要在用户点击注销时触发通知并在每个具有 CLLocationManager 的类中监听它,然后执行将其拆除的逻辑。
Sounds like you just need to fire off a notification when the user hits logout and listen for it in each of the classes that have a
CLLocationManager
then do the logic for tearing it down.作为不同的解决方案,为什么不将单例
CLLocationManager
附加到委托(或某些CustomLocationManager
类上的静态共享管理器)?让 4 个位置管理器只有一个用户似乎是一种浪费...然后您可以使用每个注销按钮中的相同代码来释放它
as a different solution why not have a singleton
CLLocationManager
attached to the delegate (or static shared manager on someCustomLocationManager
class)? It seems a waste to have 4 location managers with only one user...you can then release it with the same code from each logout button