---
title: "unitString(fromMeters:usedUnit:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/lengthformatter/unitstring(frommeters:usedunit:)"
---

# unitString(fromMeters:usedUnit:)

Returns the unit string for the provided value.

## Declaration

```swift
func unitString(fromMeters numberInMeters: Double, usedUnit unitp: UnsafeMutablePointer<LengthFormatter.Unit>?) -> String
```

## Parameters

- `numberInMeters`: The length’s value in meters.
- `unitp`: An output parameter. This will hold the doc://com.apple.foundation/documentation/Foundation/LengthFormatter/Unit value that corresponds to the returned units.

## Return Value

Return Value A localized string representing the unit.

## Discussion

Discussion This method selects the correct unit based on the formatter’s locale, the magnitude of the value, and the isForPersonHeightUse property.

## 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(fromValue:unit:)](foundation/lengthformatter/unitstring(fromvalue:unit:).md)
- [unitStyle](foundation/lengthformatter/unitstyle.md)
