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 : i don't want my download to continue when the user enter backgro开发者_Python百科und.
Thanks,
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.
EDIT: 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];
when you go to the background.
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.
精彩评论