ASIHTT prequest和背景 [英] ASIHTTPRequest and background

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

问题描述

笏发生,当我们开始一个要求,我们进入后台请求之前完成?我们不得不取消了吗?什么是这样做的正确方法?

Wat happen when we start a request and we enter the background before the request is finished ? Do we have to cancel it ? What is the right way to do so ?

PS:我不希望我的下载,继续当用户进入后台

PS : i don't want my download to continue when the user enter background.

谢谢,

推荐答案

文档你会看到,继续在后台请求,您需要使用专门要求采取行动;

From the documentation you will see that to continue a request in the background, you need to specifically request that action using;

[request setShouldContinueWhenAppEntersBackground:YES];

其必然结果是,如果你没有专门启用它,下载将被取消。你不应该需要采取具体行动,这样做的。

The corollary is that if you don't specifically enable it, the download will be cancelled. You should not need to take specific action to do so.

编辑:查看源,它看起来像下载将没有明确ASIHTT prequest被取消,但将无法完成,因为该操作系统很可能会为你这样做。如果你真的想确保它取消了,也许是因为讨厌的东西发生,如果你不这样做,你可以随时使用;

Looking at the source, it looks like the download won't explicitly be cancelled by ASIHTTPRequest, but will fail to complete because the operating system is likely to do so for you. If you really want to be sure that it cancelled, perhaps because something nasty happens if you don't, you can always use;

[request cancel];

当你去后台。

我个人preFER是在正在发生的事情的控制权,并会明确取消的事情,我没想到,由于进入后台完成。因为你知道100%是怎么回事,它的清洁和更安全。

Personally I prefer to be in control of what is going on and would explicitly cancel things I wasn't expecting to finish due to going into the background. It's cleaner and safer because you know 100% what is going on.

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

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