taiyang2014

post异步请求

//创建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);
   }];

 

posted on 2015-03-03 11:55  taiyang2014  阅读(209)  评论(0编辑  收藏  举报

导航