---
title: "unitString(fromKilograms:usedUnit:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/massformatter/unitstring(fromkilograms:usedunit:)"
---

# unitString(fromKilograms:usedUnit:)

Returns the unit string for the provided value.

## Declaration

```swift
func unitString(fromKilograms numberInKilograms: Double, usedUnit unitp: UnsafeMutablePointer<MassFormatter.Unit>?) -> String
```

## Parameters

- `numberInKilograms`: The mass’s value in kilograms.
- `unitp`: An output parameter. This will hold the doc://com.apple.foundation/documentation/Foundation/MassFormatter/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 isForPersonMassUse property. The value, once converted into the appropriate unit, determines whether the unit string 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(fromValue:unit:)](foundation/massformatter/unitstring(fromvalue:unit:).md)
- [unitStyle](foundation/massformatter/unitstyle.md)
