title: Why is my NSURLConnection returning null?
body: <p>I'm making an NSURLConnection to my server but <code>responseData</code> ends up being null in <code>connectionDidFinishLoading</code> and I can't figure out why.  Here's the code for the connection:  </p>
  
  <pre><code>NSMutableData *responseData;
  
  - (void)myFunction:(id)sender {
  
    NSString *url = @"http://www.example.com/";
  
    NSURL *URL = [NSURL URLWithString:url];
  
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];
  
    NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
  
    [connection start];
  }
  
  
  // NSURLConnection Delegates
  - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    [responseData setLength:0];
  }
  
  
  - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [responseData appendData:data];
  }
  
  
  - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
  
  } // end connectionDidFinishLoading
  
  - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
    NSLog(@"Connection error: %@",[error description]);
  }
  </code></pre>