---
title: "string(for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/bytecountformatter/string(for:)"
---

# string(for:)

Formats obj as a byte count (if obj is an NSNumber) or specific byte measurement (if obj is an NSMeasurement) using the receiver’s settings.

## Declaration

```swift
func string(for obj: Any?) -> String?
```

## Discussion

Discussion Returns nil if obj is not of the correct class (NSNumber or NSMeasurement). Throws an exception if obj is an NSMeasurement whose unit does not belong to the NSUnitInformationStorage dimension.
