iOS core note-The difference between network programming-asi and AFN

Source: Internet
Author: User

First, the bottom realization:
    • 1> AFN is based on OC Nsurlconnection and nsurlsession;
    • The bottom of 2> ASI is based on the cfnetwork framework of pure C language;
    • The operating performance of the 3> ASI is higher than AFN.
Ii. data processing for the return of the server

1> ASI does not directly provide data processing methods to the server, directly return to data\string;

2> AFN provides a variety of ways to process server data:

    • JSON processing;
    • XML processing;
    • Other processing.
Third, the process of monitoring the request:

1> AFN provides success and failure two blocks to listen for requests (only for success and failure)

    • Success: Call after successful request;
    • Failure: Called after the request failed.

The 2> ASI offers 3 solutions, each of which listens to the complete process of the request.
(Listener requests Start, receive response header information, receive specific data, accept, request failed)

    • Become an agent, abide by the agreement, implement the agent method in the agreement;
    • Become an agent, do not abide by the agreement, custom proxy method;
    • Set block.
Iv. Ease of use in file downloads and file uploads:

1> AFN:

    • Not easy to listen to download progress and upload progress;
    • It is not easy to implement the breakpoint continuation;
    • Generally only used to download a small file.

2> ASI:

    • Very easy to achieve download and upload;
    • Very easy to listen to download progress and upload progress;
    • It is very easy to implement the breakpoint continuation;
    • Download either large or small files are OK.
Five, ASI provides more practical features:

1> control circle should not be in the request process relay;

2> can easily set dependencies between requests: Each request is a Nsoperation object;

3> can manage all requests uniformly (also specifically providing a call to Asinetworkqueue to manage all request objects)

      • Pause \ Resume \ Cancel all requests;
      • Listen for download progress and upload progress for all requests in the entire queue.

iOS core note-The difference between network programming-asi and AFN

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.