<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FormatStyle/byteCount(style:allowedUnits:spellsOutZero:includesActualByteCount:)-ev0u",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation11FormatStylePA2A11MeasurementVAASo11NSDimensionCRbzrlEABVAASo24NSUnitInformationStorageCRszrlE9ByteCountVyAJ__GRszrlE04byteJ05style12allowedUnits13spellsOutZero014includesActualiJ0AmA0ijbC0V0C0O_AT0N0VS2btFZ"
  },
  "title" : "byteCount(style:allowedUnits:spellsOutZero:includesActualByteCount:)"
}
-->

# byteCount(style:allowedUnits:spellsOutZero:includesActualByteCount:)

Returns a format style to format a data storage value represented with Foundation’s measurement type.

```
static func byteCount(style: Measurement<UnitInformationStorage>.FormatStyle.ByteCount.Style, allowedUnits: Measurement<UnitInformationStorage>.FormatStyle.ByteCount.Units = .all, spellsOutZero: Bool = true, includesActualByteCount: Bool = false) -> Self
```

## Parameters

`style`

The style of byte count to express, such as memory or file system storage.

`allowedUnits`

The units the format style can use to express the byte count.

`spellsOutZero`

A Boolean value that indicates whether the format style should spell out zero-byte values as text, like `Zero kB`.

`includesActualByteCount`

A Boolean value that indicates whether the format style should include the exact byte count, in addition to expressing it in terms of units. For example, `1 kB (1,024 bytes)`.

## Return Value

A format style for formatting a measurement of data storage, customized with the provided behaviors.

## Discussion

Use this type method when the call point allows the use of [`Measurement.FormatStyle.ByteCount`](/documentation/Foundation/Measurement/FormatStyle/ByteCount). You typically do this when calling the [`formatted()`](/documentation/Foundation/Measurement/formatted()) on a [`Measurement`](/documentation/Foundation/Measurement) whose unit type is [`UnitInformationStorage`](/documentation/Foundation/UnitInformationStorage), as seen in the following example.

```swift
let count = Measurement(value: 1024, unit: UnitInformationStorage.bytes)
let formatted = count.formatted(.byteCount(style: .memory)) // "1 kB"
```

---

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)