将数据附加到POST NSURLRequest [英] Append data to a POST NSURLRequest
本文介绍了将数据附加到POST NSURLRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将数据附加到现有 POST
NSURLRequest
?我需要添加一个新参数 userId = 2323
。
How do you append data to an existing POST
NSURLRequest
? I need to add a new parameter userId=2323
.
推荐答案
如果您不希望使用第三方课程,以下是您设置帖子正文的方式......
If you don't wish to use 3rd party classes then the following is how you set the post body...
NSURL *aUrl = [NSURL URLWithString:@"http://www.apple.com/"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aUrl
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
NSString *postString = @"company=Locassa&quality=AWESOME!";
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connection= [[NSURLConnection alloc] initWithRequest:request
delegate:self];
只需将您的键/值对附加到帖子字符串
Simply append your key/value pair to the post string
这篇关于将数据附加到POST NSURLRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文