<!--
{
  "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(_:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLConnectionDataDelegate(im)connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:"
  },
  "title" : "connection(_:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)"
}
-->

# connection(_:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)

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

```
optional func connection(_ connection: NSURLConnection, didSendBodyData bytesWritten: Int, totalBytesWritten: Int, totalBytesExpectedToWrite: Int)
```

## Parameters

`connection`

The connection sending the message.

`bytesWritten`

The number of bytes written in the latest write.

`totalBytesWritten`

The total number of bytes written for this connection.

`totalBytesExpectedToWrite`

The number of bytes the connection expects to write.

## Discussion

This method provides an estimate of the progress of a URL upload.

The value of `totalBytesExpectedToWrite` may change during the upload if the request needs to be retransmitted due to a lost connection or an authentication challenge from the server.

---

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)