iOS Development Network Programming-using Nsurlconnection for large file downloads

Source: Internet
Author: User

Main ideas (implementing the download data fragment write cache)

1, using Nsurlconnectiondatadelegate and proxy method.
2. In the agent method that successfully gets the response, obtain the full path to the sandbox and create an empty file and file handle under the path.
3, in the proxy method to get data, first set the handle at the end of the sandbox full path file, and then write data through the handle.
4. In the agent method where the file is downloaded, close the handle and set the handle reference to the nil release handle and pointer.

Use the thought diagram of the handle (the red arrow indicates the handle, and the gray arrow indicates the path of the move):



Code keywords:

Class: Methods of Nsfilehandle
1, Filehandleforwritingatpath through the file path to get the file, and create a file handle
2. seektoendoffile file handle moved to end of file
3. WriteData writes data to file
4. CloseFile Close File handle

code example:

API interface for doing code exercises

MP4 Little Video: Http://120.25.226.186:32812/resources/videos/minion_03.mp4

about using Nsurlconnection to implement large file breakpoints download please see next: iOS Development Network Programming-using Nsurlconnection to achieve large file breakpoints to continue downloading.

Reproduced please specify the source: http://www.cnblogs.com/goodboy-heyang/p/5189817.html, respect for the fruits of labor.

iOS Development Network Programming-using Nsurlconnection for large file downloads

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.