MKNetWorkHost and MKNetworkRequest in MKNetworkKit of the latest version should be noted, mknetworkkit
The three most common network frameworks in ios are ASIHTTPRequest, AFNetworking, and MKNetworkKit ". However, ASIHTTPRequest is no longer updated and does not support ARC. But as a beginner, it is a pity that we don't know this class library, at the same time, it is also convenient for many training institutions to talk about it. There is also a AFNetworking, which is the longest third-party class library used by many developers. I can see a lot of classes with powerful functions. Today, we will mainly talk about MKNetworkKit. I search for this information on Baidu in the old version and seldom involve the new version (MKNetworkEngine and MKNetworkoperation ), FQ Google only found the most detailed usage. Bytes.
This URL has a detailed description of the latest MKNetwork usage. Take post request as an Example
// Set the request path, which is the content after the Host Name (Domain Name and IP address). (Note that you cannot add the host name or receive a warning) this is because the host name is marked with "/" before the request.
NSString * path = [[NSString alloc] initWithFormat: @ "/login. aspx"];
// Set the Request body
NSMutableDictionary * param = [[NSMutableDictionary alloc] init];
[Param setValue: @ "Window1 $ Toolbar1 $ btn_login" forKey: @ "_ EVENTTARGET"];
[Param setValue: signINTextFied. text forKey: @ "*********"];
[Param setValue: passwordTextFied. text forKey: @ "********"];
[Param setValue: @ "student" forKey: @ "************"];
[Param setValue: @ "true" forKey: @ "*******************"];
[Param setValue: @ "false" forKey: @ "***************];
[Param setValue: @ "********************"];
[Param setValue: @ "false" forKey: @ "***********************"];
[Param setValue: @ "false" forKey: @ "****************"];
// The instance is responsible for managing the network queue parameter as the host name (note that HTTP and WWW cannot be added before)
MKNetworkHost * hostNet = [[MKNetworkHost alloc] initWithHostName: @ "192.168.22.333: 42"];
// Instance a request object MKNetworkRequest
MKNetworkRequest * requestNetWork = [hostNet requestWithPath: path params: param httpMethod: @ "POST"];
[RequestNetWork addCompletionHandler: ^ (MKNetworkRequest * completedRequest ){
[Self RequsetGETUrl];
}];
[HostNet startRequest: requestNetWork];