title: Retrieve HTTPResponse/HTTPRequest status codes in iOS?
body: <p>I need to check and evaluate the HTTP Status Codes in my iPhone app. I've got an NSURLRequest object and an NSURLConnection that successfully (I think) connect to the site:</p>
  
  <pre><code>// create the request
  NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]
                          cachePolicy:NSURLRequestUseProtocolCachePolicy
                      timeoutInterval:60.0];
  // create the connection with the request
  // and start loading the data
  NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
  if (theConnection) {
      // Create the NSMutableData that will hold
      // the received data
      // receivedData is declared as a method instance elsewhere
      receivedData=[[NSMutableData data] retain];
  } else {
      // inform the user that the download could not be made
  }
  </code></pre>
  
  <p>I got this code here: <a href="https://web.archive.org/web/20100908130503/http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html" rel="nofollow noreferrer">https://web.archive.org/web/20100908130503/http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html</a></p>
  
  <p>But it doesn't (as far as I can see) say anything about accessing HTTP Status codes.</p>
  
  <p>How to make a connection to a site and then check the HTTP Status Codes of that connection?</p>