Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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 setHTTPMethod不再工作了?_Objective C_Xcode - Fatal编程技术网

Objective c setHTTPMethod不再工作了?

Objective c setHTTPMethod不再工作了?,objective-c,xcode,Objective C,Xcode,这是我在IOS中开始编程以来一直在使用的代码。虽然去年我停了下来,现在我回来了,它不再发帖了。事实上,我检查了代理,什么也没发生。我甚至试着把它放在[超级视图下载]下;Xcode 6/iOS 8有什么变化吗?谢谢:-附言。对不起我的英语 NSString *post = @"car=geo"; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString

这是我在IOS中开始编程以来一直在使用的代码。虽然去年我停了下来,现在我回来了,它不再发帖了。事实上,我检查了代理,什么也没发生。我甚至试着把它放在[超级视图下载]下;Xcode 6/iOS 8有什么变化吗?谢谢:-附言。对不起我的英语

NSString *post = @"car=geo";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://thesitehere"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];

谢谢你们,我忘了连接我知道已经一年了。哈哈。 再次感谢

NSURLConnection *myCon = [[NSURLConnection alloc] initWithRequest:request delegate:self];

你实际发出请求的代码在哪里?一个请求需要一个操作来使用它。我让它由一个iAction控制,我运行一个NSLog,我确实得到了一个回复。我甚至可以很好地更改按钮标题。它只是没有发出这个请求。感谢You@MikeGoldsmith请显示使用此请求的NSURLConnection代码。