One of the main components of the the OS X application I work on is a downloading system, which is built around NSURLDownload.
The vast majority of our users (as well as our internal dev team) don't have any issues with downloading files. However we seem to have a small percentage of random users (1-2%) worldwide that do. For those users, NSURLDownload's downloadDidFinish: delegate method is being called before the download is complete. For example, if the user tries to download a 5 GB file, downloadDidFinish: might get called after just 3.5 GB of data have been transfered, resulting in an incomplete file. Obviously this is causing a lot of frustration with users.
We've spent a good deal of time on this problem but haven't made much progress. We've seen that there's at least one case where OS X (erroneously?) calls downloadDidFinish: too early, and that's when the Mac volume runs low on free space. This struck me as odd, since why wouldn't the download:didFailWithError: delegate method be called instead? But the vast majority of users with incomplete downloads have plenty of disk space, so we don't think low disk space is their problem.
So I guess my question is: Do you guys know of any reason (other than low disk space) why NSURLDownload downloadDidFinish: might be called before the download is complete? Thanks for any advice you can give us.
Anoop's suggestion above looks to be correct. We went back to the drawing board and simulated Server-side disconnects better than we had been. We found that by doing so, our Client software would receive NSURLDownload:downloadDidFinish: notifications.
Personally I think it's strange that OS X would send our NSURLDownload objects a "finish" (rather than a "fail") notification in this situation. But I guess that's the way Apple wants it to work.