NSURLConnectionDownloadDelegate file issue

前端 未结 4 509
清歌不尽
清歌不尽 2021-02-08 03:07

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, NSURLConne

相关标签:
4条回答
  • 2021-02-08 03:43

    Folks,

    I've recently discovered this new NSURLConnectionDataDelegate protocol. However, the iOS 5 documentation is incomplete.

    The New NSURLConnectionDataDelegate protocol is in the documentation, but the new version of NSURLConnection that uses it is not. That documentation still tells us to use the now deprecated NSURLConnectionDelegate protocol methods.

    I gather that NSURLConnection will now download data from a remote URL directly to a file on the local disk, much like the NSURLDownload class in Mac OS. How do I figure out how this works?

    The header for NSURLConnection hints that the connection object deduces what you want based on which version of the NSURLConnectionDelegate protocol the delegate conforms to. That seems really screwy. I've never heard of using the protocol conformity of a delegate as a way of controlling the behavior of a class before.

    0 讨论(0)
  • 2021-02-08 03:52

    Even now NSURLConnectionDownloadDelegate doens't work.

    Here is a good replacement: http://github.com/jbrennan/JBContainedURLConnection

    0 讨论(0)
  • 2021-02-08 04:01

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

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

    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.

    0 讨论(0)
  • 2021-02-08 04:04

    Documentation tells the file is only guaranteed to exist while the delegate method is called so you will need to copy it somewhere else the moment the delegate method is called.

    Google tells me people are having problems when the Server sends a cryptic filename and/or mime-type.

    0 讨论(0)
提交回复
热议问题