+ (Nsmutableurlrequest *) Putrequestwithurl: (NSString *) urlstring httpmethod: (NSString *) HttpMethod HTTPBody: ( NSString *) Httpbody;+ (Nsmutableurlrequest *) Putrequestwithurl: (NSString *) urlstring httpmethod: (NSString *) HttpMethod HTTPBody: ( NSString *) httpbody{//1. Create a URLNsurl *url =[Nsurl urlwithstring:urlstring]; //2. Create Nsurlrequest//Note: If you need to set the request body or other request parameters, you must use the Nsurlrequest subclassNsmutableurlrequest *request =[Nsmutableurlrequest Requestwithurl:url]; //Setup Mode//Note: You must capitalize.Request. HttpMethod =HttpMethod; //set the request body//Note: As long as the post request, the system is automatically added inside? //Post Send Chinese no problemRequest. Httpbody =[Httpbody datausingencoding:nsutf8stringencoding]; //setting the time-out periodRequest.timeoutinterval =Ten; [Request SetValue:@"application/x-www-form-urlencoded"Forhttpheaderfield:@"Contsetent-type"]; returnrequest; }
Apple Native Request Encapsulation