title: Request with NSURLRequest
body: <p>I'm trying do to an app which uses a database (actually in my localhost), I tried with ASIHTTPRequest but having so much troubles with iOS 5 (I learnt how to use ASIHTTPRequest form there : <a href="http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service" rel="nofollow noreferrer">http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service</a></p>
  
  <p>Now i'm trying with the API provided by Apple : NSURLRequest / NSURLConnection etc,...</p>
  
  <p>I read the Apple online guide and make this first code :</p>
  
  <pre><code>- (void)viewDidLoad
  {
  
      [super viewDidLoad];
  
       // Do any additional setup after loading the view, typically from a nib.
  
  
  
      NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL
  
                                  URLWithString:@"http://localhost:8888/testNSURL/index.php"]
  
                                  cachePolicy:NSURLRequestUseProtocolCachePolicy
  
                                  timeoutInterval:60.0];
  
  
  
      [request setValue:@"Hello world !" forKey:@"myVariable"];
  
  
  
      NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
  
      if (theConnection) {
  
          receiveData = [NSMutableData data];   
  
      }
  
  }
  </code></pre>
  
  <p>I added the delegates needed by the API</p>
  
  <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
  
  - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
  
  - (void)connection:(NSURLConnection *)connection
  
  - (void)connectionDidFinishLoading:(NSURLConnection *)connection
  </code></pre>
  
  <p>Here is my php code :</p>
  
  <pre><code>&lt;?php
  if(isset($_REQUEST["myVariable"])) {
      echo $_REQUEST["myVariable"];
  }
  else    echo '$_REQUEST["myVariable"] not found';
  ?&gt;
  </code></pre>
  
  <p>So what is wrong? When I start the app, it will immediately crash with this output :</p>
  
  <p>**</p>
  
  <pre><code>**&gt; 2012-04-09 22:52:16.630 NSURLconnextion[819:f803] *** Terminating app
  &gt; due to uncaught exception 'NSUnknownKeyException', reason:
  &gt; '[&lt;NSURLRequest 0x6b32bd0&gt; setValue:forUndefinedKey:]: this class is
  &gt; not key value coding-compliant for the key myVariable.'
  &gt; *** First throw call stack: (0x13c8022 0x1559cd6 0x13c7ee1 0x9c0022 0x931f6b 0x931edb 0x2d20 0xd9a1e 0x38401 0x38670 0x38836 0x3f72a
  &gt; 0x10596 0x11274 0x20183 0x20c38 0x14634 0x12b2ef5 0x139c195 0x1300ff2
  &gt; 0x12ff8da 0x12fed84 0x12fec9b 0x10c65 0x12626 0x29dd 0x2945) terminate
  &gt; called throwing an exception**
  </code></pre>
  
  <p>**</p>
  
  <p>I guess, it means that somethings is wrong with this line :</p>
  
  <pre><code>[request setValue:@"Hello world !" forKey:@"myVariable"];
  </code></pre>
  
  <p>It actually works if I comment this line.</p>
  
  <p>My question is : How can I send datas to a PHP API, using NSURLRequest and NSURLConnexion?</p>
  
  <p>Thank you for helping.</p>
  
  <p>P.S. By the way, I have poor knowledges about server, PHP ect,...</p>