NSURLConnection provides support for downloading the contents of an NSURLRequest in a synchronous manner using the class method sendSynchronousRequest:returningResponse:error:. Using this method is simple and convenient, but has limitations:
The client application blocks until the data has been completely received, an error is encountered, or the request times out.
Minimal support is provided for requests that require authentication.
There is no means of modifying the default behavior of response caching or accepting server redirects.
If the download succeeds the contents of the request is returned as an NSData object and an NSURLResponse for the request is returned by-reference. If NSURLConnection is unable to download the URL the method will return nil and any available NSError instance by-reference in the appropriate parameter.
If the request requires authentication in order to make the connection, valid credentials must already be available in the NSURLCredentialStorage, or must be provided as part of the requested URL. If the credentials are not available or fail to authenticate, the URL loading system will respond by sending the NSURLProtocol subclass handling the connection a continueWithoutCredentialForAuthenticationChallenge: message.
When a synchronous connection attempt encounters a server redirect, the redirect is always honored. Likewise the response data is stored in the cache according to the default support provided by the protocol implementation.
Last updated: 2009-08-14