码迷,mamicode.com
首页 > 其他好文 > 详细

post异步请求

时间:2015-03-03 13:14:40      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:

//创建url    

NSURL *url = [[NSURL alloc] initWithString:@"http://api.hudong.com/iphonexml.do"];   

     //创建可变的url请求
    NSMutableURLRequest *mRequest = [[NSMutableURLRequest alloc] initWithURL:url];

    //设置请求方式为POST
    mRequest.HTTPMethod = @"POST";

        //设置请求参数
    NSString *sendString = @"type=focus-c";
    mRequest.HTTPBody = [sendString dataUsingEncoding:NSUTF8StringEncoding];

        //发送异步请求
   [NSURLConnection sendAsynchronousRequest:mRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
       NSLog(@"%@", data);
   }];

 

post异步请求

标签:

原文地址:http://www.cnblogs.com/tian-sun/p/4310607.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!