gpt4 book ai didi

ios - 报亭在用户关闭应用程序后恢复下载完全

转载 作者:行者123 更新时间:2023-11-28 20:40:57 28 4
gpt4 key购买 nike

我们如何在用户退出应用程序后恢复下载,而不仅仅是置于后台?

我的代码看起来像这样开始下载,我希望能够在这里确定问题是否可以恢复。

NSMutableURLRequest *nkRequest = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:30.0];
NKLibrary *library = [NKLibrary sharedLibrary];
NKIssue *issue = [library addIssueWithName:[downloadInfo objectForKey:kPackageID] date:[NSDate date]];

[[NKLibrary sharedLibrary] setCurrentlyReadingIssue:[[NKLibrary sharedLibrary] issueWithName:[downloadInfo objectForKey:kPackageID]]];
NKAssetDownload *asset = [issue addAssetWithRequest:nkRequest];
[asset setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:info,@"info", nil]];
[asset downloadWithDelegate:self];

最佳答案

嗯,好像挺简单的。我正在做的事情(以及 Apple 似乎是这样说的)是将以下代码放入 AppDelegate 方法 application:didFinishLaunchingWithOptions:

// Get the Library
NKLibrary *nkLib = [NKLibrary sharedLibrary];

// Loop through all 'queued' NKAssetDownloads and resume with a delegate
for(NKAssetDownload *asset in [nkLib downloadingAssets])
{
[asset downloadWithDelegate:yourDownloadDelegate];
}

这应该是您需要做的全部。这在 WWDC 2011 的 Session 504 下被简要提及。该视频和幻灯片是很好的 Newsstand-Kit 引用。我强烈建议您观看/阅读。这对我帮助很大。祝你好运!

关于ios - 报亭在用户关闭应用程序后恢复下载完全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8583652/

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