NSURLConnectionDownloadDelegate文件问题 [英] NSURLConnectionDownloadDelegate file issue

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

问题描述

现在5.0已经启动,我们可以在不违反Apple的NDA的情况下进行讨论,我对NSURLConnection的新版本存在问题。这有一个新的委托, NSURLConnectionDownloadDelegate ,有两个关键方法。

Now that 5.0 is launched and we can discuss it without breaching Apple's NDA, I have an issue with the new version of NSURLConnection. This has a new delegate, NSURLConnectionDownloadDelegate with two key methods.


  1. connection:didWyData:totalBytesWritten:expectedTotalBytes:在文件下载进行时重复调用

  1. connection:didWriteData:totalBytesWritten:expectedTotalBytes: is invoked repeatedly while the file download is progressing

connectionDidFinishDownloading:destinationURL:在下载完成后调用一次。

connectionDidFinishDownloading:destinationURL: is called once when the download is complete.

下载的文件应该在destinationURL(至少在这个方法的生命周期中 - 意图是你得到它并将其移动到永久性的地方)。问题是:它不存在。那个目录是空的。我已将此报告为Apple的错误,他们告诉我这是他们已经知道的问题的重复。

The downloaded file should then be at destinationURL (at least for the life of this method - the intent is that you get it and move it somewhere permanent). The issue is : it's not there. That directory is empty. I have reported this as a bug to Apple and they tell me it is a duplicate of an issue that they are already aware of.

如果有人有解决方法,或者发现他们可以成功使用这个代表,请告诉我。

If anyone has a workaround for this, or finds they can use this delegate successfully, please let me know.

更新10/17/2011:我已经放弃了这一点并回到了旧代表处尽管文档中说委托方法只能通过4.3获得,但仍可在5.0中正常工作。

UPDATE 10/17/2011 : I've given up on this and gone back to the old delegate which still works fine in 5.0 even though the documentation says the delegate methods are only available thru 4.3.

推荐答案

显然只适用于报亭应用程序。这家伙可能找到了解决办法:

Apparently only for use with Newsstand apps. This guy might have found a work around:

http://adamernst.com/post/18948400652/a-replacement-for-nsurlconnectiondownloaddelegate

或者,只需使用NSURLConnection。但是如果你实现NSURLDownloadDelegate方法,它们似乎会覆盖标准的NSURLConnection委托方法。如果它是你想要的NSURLConnectionDownloadDelegate的方便的didWriteData:方法,例如要更新UIProgressView,您可以通过从http响应中获取总文件大小,并使用NSURLConnection的didReceiveData:方法来实现相同目的。

Alternatively, just use NSURLConnection. But heads up if you implement the NSURLDownloadDelegate methods, they appear to override the standard NSURLConnection delegate methods. If it's the handy didWriteData: method of NSURLConnectionDownloadDelegate that you want, e.g. to update a UIProgressView, you can achieve the same by grabbing the total file size from the http response, and by using the didReceiveData: method of NSURLConnection.

这篇关于NSURLConnectionDownloadDelegate文件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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