NSURLConnection Class Reference
Overview
An NSURLConnection object provides support to perform the loading of a URL request. The interface for NSURLConnection is sparse, providing only the controls to start and cancel asynchronous loads of a URL request.
NSURLConnection’s delegate methods allow an object to receive informational callbacks about the asynchronous load of a URL request. Other delegate methods provide facilities that allow the delegate to customize the process of performing an asynchronous URL load.
Note that these delegate methods will be called on the thread that started the asynchronous load operation for the associated NSURLConnection object.
NSURLConnection retains its delegate when it is initialized. It releases the delegate when the connection finishes loading, fails, or is canceled.
The following contract governs the delegate methods defined in this interface:
Zero or more connection:willSendRequest:redirectResponse: messages will be sent to the delegate before any further messages are sent if it is determined that the download must redirect to a new location. The delegate can allow the redirect, modify the destination or deny the redirect.
Zero or more connection:didReceiveAuthenticationChallenge: messages will be sent to the delegate if it is necessary to authenticate in order to download the request and NSURLConnection does not already have authenticated credentials.
Zero or more connection:didCancelAuthenticationChallenge: messages will be sent to the delegate if the connection cancels the authentication challenge due to the protocol implementation encountering an error.
Zero or more connection:didReceiveResponse: messages will be sent to the delegate before receiving a connection:didReceiveData: message. The only case where connection:didReceiveResponse: is not sent to a delegate is when the protocol implementation encounters an error before a response could be created.
Zero or more connection:didReceiveData: messages will be sent before any of the following messages are sent to the delegate: connection:willCacheResponse:, connectionDidFinishLoading:, connection:didFailWithError:.
Zero or one connection:willCacheResponse: messages will be sent to the delegate after connection:didReceiveData: is sent but before a connectionDidFinishLoading: message is sent.
Unless a NSURLConnection receives a cancel message, the delegate will receive one and only one of connectionDidFinishLoading:, or connection:didFailWithError: message, but never both. In addition, once either of messages are sent, the delegate will receive no further messages for the given NSURLConnection.
NSURLConnection also has a convenience class method, sendSynchronousRequest:returningResponse:error:, to load a URL request synchronously.
NSHTTPURLResponse is a subclass of NSURLResponse that provides methods for accessing information specific to HTTP protocol responses. An NSHTTPURLResponse object represents a response to an HTTP URL load request.
Overview
An NSURLConnection object provides support to perform the loading of a URL request. The interface for NSURLConnection is sparse, providing only the controls to start and cancel asynchronous loads of a URL request.
NSURLConnection’s delegate methods allow an object to receive informational callbacks about the asynchronous load of a URL request. Other delegate methods provide facilities that allow the delegate to customize the process of performing an asynchronous URL load.
Note that these delegate methods will be called on the thread that started the asynchronous load operation for the associated NSURLConnection object.
NSURLConnection retains its delegate when it is initialized. It releases the delegate when the connection finishes loading, fails, or is canceled.
The following contract governs the delegate methods defined in this interface:
Zero or more connection:willSendRequest:redirectResponse: messages will be sent to the delegate before any further messages are sent if it is determined that the download must redirect to a new location. The delegate can allow the redirect, modify the destination or deny the redirect.
Zero or more connection:didReceiveAuthenticationChallenge: messages will be sent to the delegate if it is necessary to authenticate in order to download the request and NSURLConnection does not already have authenticated credentials.
Zero or more connection:didCancelAuthenticationChallenge: messages will be sent to the delegate if the connection cancels the authentication challenge due to the protocol implementation encountering an error.
Zero or more connection:didReceiveResponse: messages will be sent to the delegate before receiving a connection:didReceiveData: message. The only case where connection:didReceiveResponse: is not sent to a delegate is when the protocol implementation encounters an error before a response could be created.
Zero or more connection:didReceiveData: messages will be sent before any of the following messages are sent to the delegate: connection:willCacheResponse:, connectionDidFinishLoading:, connection:didFailWithError:.
Zero or one connection:willCacheResponse: messages will be sent to the delegate after connection:didReceiveData: is sent but before a connectionDidFinishLoading: message is sent.
Unless a NSURLConnection receives a cancel message, the delegate will receive one and only one of connectionDidFinishLoading:, or connection:didFailWithError: message, but never both. In addition, once either of messages are sent, the delegate will receive no further messages for the given NSURLConnection.
NSURLConnection also has a convenience class method, sendSynchronousRequest:returningResponse:error:, to load a URL request synchronously.
NSHTTPURLResponse is a subclass of NSURLResponse that provides methods for accessing information specific to HTTP protocol responses. An NSHTTPURLResponse object represents a response to an HTTP URL load request.