我们可以用什么来代替nstimer? [英] What can we use instead of nstimer?
本文介绍了我们可以用什么来代替nstimer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用 [locationManager startUpdatingLocation]
在后台获取GPS位置,但我不知道如何安排它。我已经使用NSTimer进行调度,但其中很多人说如果应用程序进入后台,NSTimer将过期。
我想知道如何调度方法,如果我们不使用NSTimers。
解决方案
Apple提供了5种应用程序任务,可以在后台运行:
- 在后台播放音频内容给用户的应用,例如音乐播放器应用
- 能够随时向用户通知其位置的应用程序,例如导航应用程序。
- 支持语音网络协议(VoIP)的应用程序
- 需要下载和处理新内容的报亭应用程序
I can get the GPS location in the background using
[locationManager startUpdatingLocation]
, but I don't know how to schedule it. I have used NSTimer for scheduling but many of them are saying that NSTimer will get expire if the application enters background.I want to know how to schedule calling the method , if we are not using NSTimers.
解决方案Apple provides 5 kinds of app task to run in background:
- Apps that play audible content to the user while in the background, such as a music player app
- Apps that keep users informed of their location at all times, such as a navigation app
- Apps that support Voice over Internet Protocol (VoIP)
- Newsstand apps that need to download and process new content
- Apps that receive regular updates from external accessories
Refer this link for location updates while app is in background
Also refer this tutorial for further help
这篇关于我们可以用什么来代替nstimer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文