1
这里是我的代码,我的代码正在工作,但我的问题是当我尝试传递变量而不是名称NSString *postString = @"username=example&firstlastname=example";
它说我想要= TextField值的示例,所以我该怎么做?我试过后字符串追加字符串,但它没有工作。请帮助如何在Cocoa中创建POST请求?
NSURL *aUrl= [NSURL URLWithString:@"http://xxxx/iqueueinsertinjoinq.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aUrl
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
NSString *postString = @"username=example&firstlastname=example";
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
//NSURLConnection *connection= [[NSURLConnection alloc] initWithRequest:request delegate:self];
[[NSURLConnection alloc] initWithRequest:request delegate:self ];}
非常感谢你的回答静静:) – user2857802