上的NSTimer后台工作 [英] NSTimer on background IS working

查看:148
本文介绍了上的NSTimer后台工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不理解的事,但的NSTimer 在我的应用程序绝对是后台运行。我有一个的NSLog 在mehod由定时器运行,它是记录,而它的背景。这是对iPhone 4的iOS 4.2.1。我宣布在Info.plist中的位置的后台支持。

I don't understand it at all but NSTimer in my app definitely is running in background. I have a NSLog in mehod run by the timer and it is logging while it's in background. It's on iPhone 4 with iOS 4.2.1. I have declared location background support in Info.plist.

我在这里和其他地方阅读文档和许多讨论,它不应该是可能的。它是一个iOS的错误吗?或无证功能?我不想与iOS 4.3的到来,苹果悄悄地固定​​它和应用程序将无法正常工作使用它,并找出在不久的将来,例如。

I read the docs and many discussions here and elsewhere and it shouldn't be possible. Is it an iOS bug? Or undocumented feature? I don't want to use it and find out in near future, for example with coming of iOS 4.3 that Apple silently "fixed" it and the app won't be working.

有谁知道更多一点吗?

推荐答案

的NSTimer 即将每当主runloop运行开火。苹果公司不作任何承诺,我知道取消预定定时器或prevent主要runloop运行。这是你的责任,你取消预定定时器和释放资源,当你移动到背景。苹果公司是不会为你做它。他们可能会,但是,杀了你当你不应该运行或使用太多秒。

NSTimer is going to fire whenever the main runloop is running. Apple makes no promises that I know of to unschedule timers or to prevent the main runloop from running. It's your responsibility to unschedule your timers and release resources when you move to the background. Apple isn't going to do it for you. They may, however, kill you for running when you are not supposed to or using too many seconds.

有在系统中的许多孔,使当它被未授权的​​应用程序来运行。这将是该操作系统prevent这个非常昂贵的。但是你不能依赖它。

There are many holes in the system that will allow an app to run when it isn't authorized to. It would be very expensive for the OS to prevent this. But you cannot rely on it.

这篇关于上的NSTimer后台工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆