使用 NSUserDefaults 的后台位置设置问题

发布于 2024-11-27 17:45:30 字数 205 浏览 1 评论 0原文

我将位置设置存储在设置包中。因此,当我将开关切换到“否”时,我的应用程序会停止后台定位服务。

我正在使用观察者来检测设置更改,并更新我的应用程序中的标志。问题是,如果我将开关切换到“关闭”,我的应用程序不会停止位置服务,直到我打开应用程序。这是可以理解的,因为我的观察者驻留在源代码中。有没有办法在应用程序处于后台时监听设置?我是一个iOS开发新手,所以不太了解后台和前台的概念。

I am storing Location settings in the settings bundle. So when I flip a switch to NO, my app stops the background location service.

I am using an observer to detect settings change, and updating a flag in my app. The problem is, if I flip the switch to OFF, my app does not stop the location service till I open the app. This is understandable, since my observer resides in the source code. Is there a way to listen for the settings while the app is in the background? I am an iOS development newbie, so I do not understand the concept of background and foreground so much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千纸鹤 2024-12-04 17:45:30

我发现这是不可能的。

Its not possible is what I found.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文