To do iOS development, speaking of network requests, we may all coincide with the mention of AFN, you can say that everyone's network requests are packaged with AFN, AFN powerful and easy to use is indeed very good.
However, there are some problems with the version upgrade, so you have a static library that encapsulates a network request based on iOS native, allowing your line of code to implement network requests.
Based on the native iOS package of Get and post network requests, a line of code can be implemented, based on the native package, easy to use.
How to use: 1. Download the static library and import
Https://github.com/YouZhiZheShiJingCheng/YZNetWork
Import remember to tick the copy,
2. Configuration Engineering
Targets->build settings->other Linker Flags Add a-OBJC
3. Start the application
Import Header File
#import "YZNetWork.h"
Network requests
[[Yznet YZ] Ispost:yes url:@ "" withdata:@{@ "parameter": @ "number"} withsucess:^ (Nsdictionary *response) {//Request succeeded} withfalie:^ (Nserror *error) {//Request failed} andnetoff:^{//No Network}];
The first parameter indicates whether it is post, yes, yes, not no
The second parameter is the parameter of the network request, which is a dictionary with corresponding parameters and values corresponding to the parameters
The third one is the result of a successful request, and a dictionary is returned
The fourth one is the error message returned by the request failure
The last one is a situation without a network.
Remember to let the app allow access to HTTP
The simplest iOS network request