Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c URL获取/发布请求目标-c_Objective C_Url_Post_Get_Request - Fatal编程技术网

Objective c URL获取/发布请求目标-c

Objective c URL获取/发布请求目标-c,objective-c,url,post,get,request,Objective C,Url,Post,Get,Request,我必须向本地主机发送get或post请求: <?php if(@$_GET['option']) { echo "You said \"{$_GET['option']}\""; }else if(@$_POST['option']) { echo "You said \"{$_POST['option']}\""; } ?> 它可以工作,但在代码中只有一次。如果我再做一次,申请就终止了 Im尝试使用ASIFormDataRequest: ASIFormDataReq

我必须向本地主机发送get或post请求:

<?php
 if(@$_GET['option']) {
  echo "You said \"{$_GET['option']}\"";
 }else if(@$_POST['option']) {
  echo "You said \"{$_POST['option']}\"";
 }
?>
它可以工作,但在代码中只有一次。如果我再做一次,申请就终止了

Im尝试使用ASIFormDataRequest:

ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:@"http://localhost/wsh/index.php"] autorelease];
[request setPostValue:@"option" forKey:@"myFormField1"];
[request start];
NSError *error = [request error];
if (!error) {
  NSString *response = [request responseString];
  NSLog(response);
}else{
  NSLog(@"error");
}
它说:

2010-01-07 13:20:34.964 WSH[3351:903] -[NSCFString absoluteURL]: unrecognized selector sent to instance 0x160f8
2010-01-07 13:20:34.966 WSH[3351:903] error

sry for my english

您使用的是一个普通的
NSString
文本,其中需要
NSURL
对象:[……]
initWithURL:@”http://localhost/wsh/index.php“
[…]


将此更改为
initWithURL:[NSURL URLWithString:@”http://localhost/wsh/index.php“]

我想知道您是否也应该切换post值的值和键(即更改行)

[request setPostValue:@"option" forKey:@"myFormField1"];

[request setPostValue:@"option" forKey:@"myFormField1"];
[request setPostValue:@"myFormField1" forKey:@"option"];