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