基于ASIHttpRequest的POST数据的实现

来源:互联网 发布:php工程师怎么考 编辑:程序博客网 时间:2024/05/10 00:33

ASIHttpRequest库是一个非常好的库,关于其介绍,请大家查看我的前面的博文。

XCode添加第三方库

这里直接提交代码。

NSString *urlString = [NSString stringWithFormat:@"地址"];
    ASIFormDataRequest *requestForm = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:urlString]];

//设置需要POST的数据,这里提交两个数据,A=a&B=b
    [requestForm setPostValue:@"a" forKey:@"A"];
    [requestForm setPostValue:@"b" forKey:@"B"];
    [requestForm startSynchronous];

//输入返回的信息
    NSLog(@"response\n%@",[requestForm responseString]);
    [requestForm release];

不过在这之前需要导入ASIFormDataRequest的头文件。

#import "ASIFormDataRequest.h"


原创粉丝点击