首页 > 代码库 > NSMutableURLRequest的Post请求

NSMutableURLRequest的Post请求

NSData *bodyData = http://www.mamicode.com/[[bodyString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]dataUsingEncoding:NSUTF8StringEncoding];//把bodyString转换为NSData数据  "POST"];//POST请求  [request setHTTPBody:bodyData];//body 数据  [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];//请求头  NSData *returnData = http://www.mamicode.com/[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];//异步发送request,成功后会得到服务器返回的数据  >