The difference between ios-afnetworking and asihttprequest

Source: Internet
Author: User

First, the bottom realization

1, the bottom of the AFN implementation of OC-based nsurlconnection and Nsurlsession 2, ASIbottom-level implementation of Cfnetwork framework based on pure C language
3, because Nsurlconnection and nsurlsession is a layer of encapsulation above the cfnetwork, so the performance of ASI is higher than that of AFN two, the data processing returned by the server

1, ASI does not directly provide data processing methods for the server, the direct return is nsdata/nsstring
2, AFN provides a variety of data processing methods for the server
(1) JSON processing-Returns nsdictionary or Nsarray directly
(2) XML processing-Returns XML type data that needs to be parsed
(3) Other types of data processing

Third, listen to the request process

1, AFN provides success and failure two blocks to listen to the request process (only monitoring success and failure)
* Success: Call after successful request
* Failure: Call after request failed
2, ASI provides 3 sets of solutions, each set of programs can listen 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 comply with the protocol, custom proxy methods
* Set block

Iv. Ease of use in file downloads and file uploads

1, AFN
* Not easy to monitor download progress and upload progress
* Not easy to implement a breakpoint continuation
* Generally only used to download a small file
2. ASI
* Very easy to download and upload
* Very easy to listen to download progress and upload progress
* Very easy to implement the breakpoint continued to pass
* Download large files or small files can be
3. Recommend using ASI for download and upload

Five, network monitoring

1, AFN own package of network monitoring class, easy to use
2, ASI use reachability, because the use of Cocoapods download ASI, will be synchronized download reachability, but reachability as a network monitoring use more complex (compared to AFN network monitoring Class)
3, recommended to use AFN to do network monitoring-afnetworkreachabilitymanager

Vi. other useful functions provided by ASI

1, the control signal next to the circle do not transfer in the request process
2. It is easy to set up dependencies between requests: Each request is a Nsoperation object
3, can be unified management of all requests (also dedicated to provide a call asinetworkqueue to manage all the request objects)
* Suspend/Resume/Cancel all requests
* Monitor the download progress and upload progress of all requests in the entire queue

The difference between ios-afnetworking and asihttprequest

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.