Wednesday, November 21, 2012

URL GET/POST Request objective-c


I have to send get or post request to localhost:
<?php
 if(@$_GET['option']) {
  echo "You said \"{$_GET['option']}\"";
 }else if(@$_POST['option']) {
  echo "You said \"{$_POST['option']}\"";
 }
?>
ive using this code:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost/wsh/index.php?option=Hello"]];
 NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
 NSString *get = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
it works, but one time in code. if ill do it another one time, application has terminate.

No comments:

Post a Comment

Popular Posts