iOS Development Network Programming--File Download (i)

Source: Internet
Author: User

File Download Method:
    • If the downloaded file is small, download the method:

      • Directly with NSData's + (ID) Datawithcontentsofurl: (nsurl*) URL;
      • Use Nsurlconnection to send an HTTP request to download
      • If you are downloading pictures, you can also use the Sdwebimage framework (not described herein)
    • If the downloaded file is larger, download the method:

      • Using the Nsconnectiondatadelegate proxy method
      • Recommended use of nsurlsession or third-party frameworks (not described herein)
code example:

Give the API interface to do the code exercises first

Small Picture: http://img2.duitang.com/uploads/blog/201310/18/20131018213446smuw4.thumb.7000.jpeg

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

  

1. Here are two ways to download small files such as small images:

For the second type of asynchronous request through Nsurlconnection can also request a slightly larger file, such as MP4 small video files, but because the file is relatively large, it will appear wait a long time to get results, in fact, is

There is a blocking, because it is an asynchronous request, so it does not affect the main thread, if you are using a synchronous request, it will affect the main thread. You can try it, there is no source code.

2, and then introduce how to use the Nsurlconnectiondatadelegate proxy method to this MP4 small video slightly larger files

Also show the print results:

 

SOURCE Baidu Cloud Share Link: Http://pan.baidu.com/s/1jHycCIU Password: 9kum

iOS Development Network Programming--File Download (i)

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.