<!--
{
  "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/Measurement/AttributedStyle/ByteCount",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation11MeasurementVAASo11NSDimensionCRbzrlE15AttributedStyleVAASo24NSUnitInformationStorageCRszrlE9ByteCountV"
  },
  "title" : "Measurement.AttributedStyle.ByteCount"
}
-->

# Measurement.AttributedStyle.ByteCount

A format style that converts byte counts into attributed strings.

```
struct ByteCount
```

## Overview

Use the [`attributed`](/documentation/Foundation/Measurement/FormatStyle/ByteCount/attributed) modifier on a [`Measurement.FormatStyle.ByteCount`](/documentation/Foundation/Measurement/FormatStyle/ByteCount) instance to create a format style of this type.

The attributed strings that this fomat style creates contain attributes from the [`AttributeScopes.FoundationAttributes.NumberFormatAttributes`](/documentation/Foundation/AttributeScopes/FoundationAttributes/NumberFormatAttributes) attribute scope. Use these attributes to determine which runs of the attributed string represent different parts of the formatted value.

## Topics

### Creating an attributed byte count format style

[`init(style: Measurement<UnitType>.AttributedStyle.ByteCount.Style, allowedUnits: Measurement<UnitType>.AttributedStyle.ByteCount.Units, spellsOutZero: Bool, includesActualByteCount: Bool, locale: Locale)`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/init(style:allowedUnits:spellsOutZero:includesActualByteCount:locale:))

Initializes an attributed byte count format style.

### Formatting a byte count

[`func format(Measurement<UnitInformationStorage>) -> AttributedString`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/format(_:))

Formats a byte count measurment, using this style.

### Accessing style properties

[`var allowedUnits: Measurement<UnitInformationStorage>.AttributedStyle.ByteCount.Units`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/allowedUnits)

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

[`typealias Units`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/Units)

The type the measurement format style uses to represent byte-counting units.

[`var spellsOutZero: Bool`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/spellsOutZero)

A Boolean value that indicates whether the format style should spell out zero-byte values as text.

[`var includesActualByteCount: Bool`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/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.

[`var style: Measurement<UnitInformationStorage>.AttributedStyle.ByteCount.Style`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/style-swift.property)

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

[`typealias Style`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/Style-swift.typealias)

The type used to represent the style of the formatted byte count.

[`var locale: Locale`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/locale)

The locale to use to format the numeric part of the byte count.

### Modifying style locale

[`func locale(Locale) -> Measurement<UnitType>.AttributedStyle.ByteCount`](/documentation/Foundation/Measurement/AttributedStyle/ByteCount/locale(_:))

Modifies the format style to use the specified locale.

### Applying currency styles

### Applying measurement styles

### Applying list styles

### Supporting types

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`FormatStyle`](/documentation/Foundation/FormatStyle)

[`Equatable`](/documentation/Swift/Equatable)

[`Encodable`](/documentation/Swift/Encodable)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Decodable`](/documentation/Swift/Decodable)

---

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)