是否可以在后台模式下使用 startMonitoringSignificantLocationChanges 获取 ivars
当应用程序在后台或终止时使用 startMonitoringSignificantLocationChanges 时,如果检测到重大更改,Apple 会声明将应用程序带回前台。但是,我仍然能够在 didUpdateToLocation CLLocationManager 委托方法中获取 ivar 的值(之前在应用程序位于前台时设置)吗?还是丢失了?
如果丢失,在应用程序终止/后台运行并由位置管理器带回前台后保留这些值的最佳方法是什么?
When an app uses startMonitoringSignificantLocationChanges while backgrounded or when terminated, if a significant change is detected Apple states that it will bring the app back into the foreground. But, will I still be able to get the value of an ivar (previously set when the app was in the foreground) within the didUpdateToLocation CLLocationManager delegate method? Or is it lost?
If it is lost, what is the best way to persist those values after the app has terminated/backgrounded and brought back into the foreground by the location manager?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,你当然会的。失去该 ivar 值的唯一方法是,如果您的应用程序实际上已退出并重新启动,此时您并不是简单地从后台返回。
Yes of course you will. The only way you'd lose the value of that ivar is if your app has actually quit and been relaunched, at which point you're not simply coming back from the background.