gpt4 book ai didi

iphone - iOS - 如何在应用程序进入后台之前完成任务

转载 作者:行者123 更新时间:2023-11-29 04:46:30 25 4
gpt4 key购买 nike

我正在开发一个应用程序,当用户退出该应用程序时我遇到了问题。假设应用程序正在下载 3 张图像。用户退出应用程序。我怎样才能继续下载(因为我们谈论的是还剩 2 个月,而不是 500!)?我知道这样的事情:

if ([_downloader isDownloading]) {
bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
// Clean up any unfinished task business by marking where you.
// stopped or ending the task outright.
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];

// Start the long-running task and return immediately.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

NSLog(@"dispatch_async debut");

// Do the work associated with the task, preferably in chunks.

[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;

NSLog(@"dispatch_async fin");
});
}

问题是我的任务已经在处理中。我不想再次开始下载!

你有什么想法吗?

非常感谢您的回答。

最佳答案

我建议使用 ASIHTTPRequest,它具有用于恢复事件下载的内置选项。 http://allseeing-i.com/ASIHTTPRequest/

关于iphone - iOS - 如何在应用程序进入后台之前完成任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9568299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com