---
title: "unitString(fromValue:unit:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/massformatter/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: MassFormatter.Unit) -> String
```

## Parameters

- `value`: The mass’s value for the provided unit.
- `unit`: The unit to use in the resulting mass 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 Mass Strings

- [isForPersonMassUse](foundation/massformatter/isforpersonmassuse.md)
- [getObjectValue(_:for:errorDescription:)](foundation/massformatter/getobjectvalue(_:for:errordescription:).md)
- [numberFormatter](foundation/massformatter/numberformatter.md)
- [string(fromKilograms:)](foundation/massformatter/string(fromkilograms:).md)
- [string(fromValue:unit:)](foundation/massformatter/string(fromvalue:unit:).md)
- [unitString(fromKilograms:usedUnit:)](foundation/massformatter/unitstring(fromkilograms:usedunit:).md)
- [unitStyle](foundation/massformatter/unitstyle.md)
