【发布时间】:2010-08-26 09:28:03
【问题描述】:
我希望将一些数据作为数组从我的 iphone 应用程序发送到服务器
当我在将帖子作为 NSString 发送之前发布单个变量时
NSString *post =[[NSString alloc] initWithFormat:@"userName=%@&accountID=%@&",
username,accId];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
现在我希望发送这些用户名和 accountIds 的数组,我如何在 POST 中发送一个 NSArray,然后在我的服务器上的 php 中如何检索它?
谢谢
【问题讨论】: