<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/ByteCountFormatStyle/format(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation20ByteCountFormatStyleV6formatySSs5Int64VF"
  },
  "title" : "format(_:)"
}
-->

# format(_:)

Formats a numeric byte count, using this style.

```
func format(_ value: Int64) -> String
```

## Parameters

`value`

The 64-bit byte count to format.

## Return Value

A formatted representation of `value`, formatted according to the style’s configuration.

## Discussion

Use this method when you want to create a single style instance, and then use it to format multiple values. The following example creates a [`ByteCountFormatStyle`](/documentation/Foundation/ByteCountFormatStyle) to format values as kilobyte counts, then applies this style to an array of <doc://com.apple.documentation/documentation/Swift/Int64> values.

```swift
let style = ByteCountFormatStyle(style: .memory,
                                 allowedUnits: [.kb],
                                 spellsOutZero: true,
                                 includesActualByteCount: false,
                                 locale: Locale(identifier: "en_US"))
let counts: [Int64] = [0, 1024, 2048, 4096, 8192, 16384, 32768, 65536]
let formatted = counts.map ( {style.format($0) } ) // ["Zero kB", "1 kB", "2 kB", "4 kB", "8 kB", "16 kB", "32 kB", "64 kB"]
```

To format a single integer, use the <doc://com.apple.documentation/documentation/Swift/BinaryInteger> instance method <doc://com.apple.documentation/documentation/Swift/BinaryInteger/formatted(_:)-4qd73>, passing in an instance of [`IntegerFormatStyle`](/documentation/Foundation/IntegerFormatStyle), or <doc://com.apple.documentation/documentation/Swift/BinaryInteger/formatted()> to use a default style.

---

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)