ASIHTTPRequest和后台下载 [英] ASIHTTPRequest and background download

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

问题描述

我打算使用ASIHttprequest下载mp3文件。
i将需要使用队列,因为可以同时下载多个。

I was planning to use ASIHttprequest to download an mp3 file. i will need to use queues because there can be multiple simultaneous downloads.

我看到您可以使用

[request setShouldContinueWhenAppEntersBackground:YES];

如果要支持后台执行...
如果文件在后台完成,我该怎么处理这个?

if you want to support background execution... If the file completes in the background, how can i handle this?

会不会打电话给代表?
如果应用程序在代理被调用时处于背景状态,我可以从委托中获得那些通知徽章?

will the delegates be called anyway? can i make one of those notification badges from the delegate if the app was in background whenn the delegate was called?

PS:我在iOS4上,支持后台exec。

PS: I AM on iOS4, and background exec is supported.

推荐答案

应该仍然会调用 requestFinished 方法在下载之前调用 endBackgroundTask:但是,为了确保您希望执行的功能(通知徽章或某些东西),您应该使用 UIBackgroundTask

The requestFinished method should still be called before the endBackgroundTask: is called on the download; however, to ensure the functionality you want gets executed (a notification badge or something), you should use a UIBackgroundTask.

基本上,创建一个新的后台任务,并在委托完成的方法中使用 beginBackgroundTaskWithExpirationHandler:,然后在后台任务中执行任何所需的操作(请参阅apple dev指导此处)。

Basically the idea is that you create a new background task and use beginBackgroundTaskWithExpirationHandler: in the delegate finished method and then do whatever you want in the background task (see the apple dev guide about it here).

完成后,请确保在任务上调用 endBackgroundTask

Make sure you call endBackgroundTask on your task after you are done!

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

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