<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURLConnectionDataDelegate/connection(_:didReceive:)-8p5vg",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLConnectionDataDelegate(im)connection:didReceiveData:"
  },
  "title" : "connection(_:didReceive:)"
}
-->

# connection(_:didReceive:)

Sent as a connection loads data incrementally.

```
optional func connection(_ connection: NSURLConnection, didReceive data: Data)
```

## Parameters

`connection`

The connection sending the message.

`data`

The newly available data. The delegate should concatenate the contents of each `data` object delivered to build up the complete data for a URL load.

## Discussion

This method provides the only way for an asynchronous delegate to retrieve the loaded data. It is the responsibility of the delegate to retain or copy this data as it is delivered.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)