首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能在后台工作的NSOperation队列

问不能在后台工作的NSOperation队列
EN

Stack Overflow用户
提问于 2015-06-20 14:40:51
回答 1查看 499关注 0票数 1

我希望我的图片上传应该在后台工作。我启用了后台模式,并创建了一个操作队列,以便一次将多个文件上载到服务器。但只要将应用程序放到后台,NSOperation就会暂停,并在前台重新启动。当所有图像上传到服务器时,我还在启动操作队列和beginBackgroundTaskWithExpirationHandler之前添加了endBackgroundTask。

这使得所有的图片上传到服务器时,应用程序也在后台,但我的应用程序正在被杀死,我不希望应用程序被杀死。

请对我的问题提出一些解决办法。

EN

回答 1

Stack Overflow用户

发布于 2015-06-20 14:48:00

在后台运行时,应用程序的时间有限。它的分配时间已经过了,它就被杀死了。

据苹果公司称:

代码语言:javascript
复制
In your own expiration handlers, you can include additional code needed
to close out your task. However, any code you include must not take too 
long to execute because, by the time your expiration handler is called,
your app is already very close to its time limit. For this reason,
perform only minimal cleanup of your state information and end the
task.

还可以获取backgroundTimeRemaining属性的值,以检查剩余时间。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30955184

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档