我目前正在创建一个 iOS 报亭应用程序。我添加了问题并按照我想要的方式工作。但是,当我尝试去下载他们的远程文件时,它似乎不起作用。没有任何委托方法被调用,也没有文件被写入。
这是我肯定的:
- 一个 UITableViewController,它是一个 NSURLConnectionDownloadDelegate。
- UIBackgroundModes(在 info.plist 文件中)添加了“newsstand-content”
- #import 在我的 UITableViewController 的标题中
- NSURLConnectionDownloadDelegate 的方法实现
当用户同意下载问题时,会发生以下代码(注意:问题不是零):
// Download the Issue!
NSLog(@"Starting Download of issue %@",issue.name);
// Generate the url of the issue
NSURL * downloadURL = [dataManager pdfURLForIssue:issue];
// Create the request
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:downloadURL
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:30.0];
// Create the NKAssetDownload object
NKAssetDownload *assetDownload = [issue addAssetWithRequest:request];
// Set user info so I know which issue's UIProgressView to update
[assetDownload setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:issue.name,@"Name",
nil]];
// start download
[assetDownload downloadWithDelegate:self];
我不知道发生了什么。从我读过的所有内容来看,我似乎已经正确实施了一切;但是,什么都没有发生。我设置断点、NSLogs 等;但什么都没有。我什至让它运行了一段时间,然后检查了主任 [issue contentURL] 说文件也会被移动(在我的 connectionDidFinishDownloading:destinationURL: 方法中)。
有人可以帮忙吗?或者也许对我有一些想法?我已经被困了好几天了。如果您需要查看更多代码,请告诉我。谢谢!