<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionTask/countOfBytesExpectedToSend",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLSessionTask(py)countOfBytesExpectedToSend"
  },
  "title" : "countOfBytesExpectedToSend"
}
-->

# countOfBytesExpectedToSend

The number of bytes that the task expects to send in the request body.

```
var countOfBytesExpectedToSend: Int64 { get }
```

## Discussion

The URL loading system can determine the length of the upload data in three ways:

- From the length of the data object provided as the upload body.
- From the length of the file on disk provided as the upload body of an upload task (*not* a download task).
- From the `Content-Length` in the request object, if you explicitly set it.

Otherwise, the value is [`NSURLSessionTransferSizeUnknown`](/documentation/Foundation/NSURLSessionTransferSizeUnknown) (`-1`) if you provided a stream or body data object, or zero (`0`) if you did not.

---

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)