WEB开发网
开发学院手机开发iPhone 开发 iPhone开发 - 发送HttpRequest请求 阅读

iPhone开发 - 发送HttpRequest请求

 2010-09-16 23:52:00 来源:WEB开发网   
核心提示://[postBody appendData:[[NSString stringWithFormat:@""] dataUsingEncoding:NSUTF8StringEncoding]];//[postBody appendData:[[NSString stringWithFormat:@&

//[postBody appendData:[[NSString stringWithFormat:@""] dataUsingEncoding:NSUTF8StringEncoding]];

//[postBody appendData:[[NSString stringWithFormat:@""]

//dataUsingEncoding:NSUTF8StringEncoding]];

//[postBody appendData:[[NSString stringWithFormat:@""] dataUsingEncoding:NSUTF8StringEncoding]];

//设置发送内容

//[request setHTTPBody:postBody];

//获取响应

NSHTTPURLResponse* urlResponse = nil;

NSError *error = [[NSError alloc] init];

NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];

NSString *result = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

//返回的http状态

NSLog(@"Response Code: %d", [urlResponse statusCode]);

//获取返回的内容

if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 300)

{

NSLog(@"Response: %@", result);

return result;

//执行你想要的内容,代码可以写在这里

}

return @"Return value";

}

上一页  1 2 

Tags:iPhone 开发 发送

编辑录入:coldstar [复制链接] [打 印]
赞助商链接