MKNetWorkHost and MKNetworkRequest in MKNetworkKit of the latest version should be noted, mknetworkkit

Source: Internet
Author: User

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];

 

 

Related Article

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.