A protocol that most delegates of a URL connection implement to receive data associated with the connection.


@protocol NSURLConnectionDataDelegate


The NSURLConnectionDataDelegate protocol describes methods that should be implemented by the delegate for an instance of the NSURLConnection class. Many methods in this protocol existed as part of an informal protocol in previous versions of macOS and iOS.

In addition to the methods described in this protocol, an NSURLConnection delegate should also implement the methods described in the NSURLConnectionDelegate protocol.


Handling Incoming Data

- connection:didReceiveResponse:

Sent when the connection has received sufficient data to construct the URL response for its request.

- connection:didReceiveData:

Sent as a connection loads data incrementally.

Receiving Connection Progress

- connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:

Sent as the body (message data) of a request is transmitted (such as in an HTTP POST request).

- connectionDidFinishLoading:

Sent when a connection has finished loading successfully.

Handling Redirects

- connection:willSendRequest:redirectResponse:

Sent when the connection determines that it must change URLs in order to continue loading a request.

- connection:needNewBodyStream:

Called when an NSURLConnection needs to retransmit a request that has a body stream to provide a new, unopened stream.

Overriding Caching Behavior

- connection:willCacheResponse:

Sent before the connection stores a cached response in the cache, to give the delegate an opportunity to alter it.


See Also

URL Connection


An object that enables you to start and stop URL requests.


A protocol that delegates of a URL connection implement to receive status about and provide feedback to the connection object.


A protocol that delegates of a URL connection created with Newsstand Kit implement to receive data associated with a download.