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.
connection:didWriteData:totalBytesWritten:expectedTotalBytes:
is invoked repeatedly while the file download is progressing
connectionDidFinishDownloading:destinationURL:
is called once when the download is complete.
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.
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With