<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/LengthFormatter/unitString(fromValue:unit:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLengthFormatter(im)unitStringFromValue:unit:"
  },
  "title" : "unitString(fromValue:unit:)"
}
-->

# unitString(fromValue:unit:)

Returns the unit string based on the provided value and unit.

```
func unitString(fromValue value: Double, unit: LengthFormatter.Unit) -> String
```

## Parameters

`value`

The length’s value for the provided unit.

`unit`

The unit to use in the resulting length string.

## Return Value

A localized string representing the given unit. The provided value determines whether the unit is plural or singular.

## Discussion

---

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)