---
title: "unitString(fromValue:unit:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/lengthformatter/unitstring(fromvalue:unit:)"
---

# unitString(fromValue:unit:)

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

## Declaration

```swift
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

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

## See Also

### Formatting Length Strings

- [isForPersonHeightUse](foundation/lengthformatter/isforpersonheightuse.md)
- [getObjectValue(_:for:errorDescription:)](foundation/lengthformatter/getobjectvalue(_:for:errordescription:).md)
- [numberFormatter](foundation/lengthformatter/numberformatter.md)
- [string(fromMeters:)](foundation/lengthformatter/string(frommeters:).md)
- [string(fromValue:unit:)](foundation/lengthformatter/string(fromvalue:unit:).md)
- [unitString(fromMeters:usedUnit:)](foundation/lengthformatter/unitstring(frommeters:usedunit:).md)
- [unitStyle](foundation/lengthformatter/unitstyle.md)
