Network programming for iOS development--using nsurlconnection to achieve large file breakpoint continuation download is in the previous iOS Development network programming-using Nsurlconnection to achieve large file download based on
The settings for the continuation of the breakpoint. Network programming on iOS development-using Nsurlconnection to implement large file download details here, of course, will not be exhausted.
the principle of the continuation of the breakpoint :
Each time you request to download data from the server, tell the server to start the download from a location that is not yet downloaded from the entire stream of downloaded files, and then the server returns the data stream from that location.
Image:
The breakpoint continues to pass the key code:
API interface for doing code exercises :
MP4 Little Video: Http://120.25.226.186:32812/resources/videos/minion_01.mp4
Code Implementation (the following source is in the iOS development of the network programming-using Nsurlconnection to achieve large file download based on the further implementation of disconnection):
1, to achieve the download and stop the download, so you need to add two buttons, and then drag line connection what, you understand.
2. Key complete code:
For more information on using Nsurlconnection to implement a large file breakpoint download:
In my iOS development of the network programming-small file download of the essay blog post mentioned in the Response header object properties
Instead of downloading the length of the entire file, response.expectedcontentlength Returns the length of the file that will be downloaded
As a practical example: when I download the length of the 1/3 and then cancel the download, and then click to start the download again, this time Response.expectedcontentlength will return the remaining 2/3 of the length.
So use response.expectedcontentlength to be careful not to use wrong because you don't know the nature of it.
The above source code:
Reprint please specify the Source: iOS Development Network Programming-use Nsurlconnection to achieve large file breakpoints to continue downloading, respect for the fruits of labor.
iOS Development Network Programming--use nsurlconnection to achieve large file breakpoint continuation download