#define d_LocalNetAddress http://XXX.XXX.XXX.XXX/a.action
NSString * content = @"Test";
NSInputStream * nis = [[NSInputStream alloc] initWithData:[content dataUsingEncoding:NSUTF8StringEncoding] ];
NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ] initWithURL: [ NSURL URLWithString: pd_LocalNetAddress ] ];
[ request setHTTPMethod: @"POST" ];
[ request setHTTPBodyStream: nis];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
if (theConnection) {
receivedbData=[[NSMutableData data] retain];
} else {
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Succeeded! Received %d bytes of data", [receivedbData length]);
NSString * firstBuffer;
firstBuffer = [receivedbData mutableBytes];
NSLog(@"Succeeded! Received: %s", firstBuffer);
[connection release];
[receivedbData release];
}
iphone post data
最新推荐文章于 2025-06-29 16:05:22 发布
本文介绍了一个使用Objective-C实现的简单iOS应用示例,该应用通过POST方法向本地网络地址发送字符串内容,并接收服务器返回的数据。
1万+

被折叠的 条评论
为什么被折叠?



