<!--
{
  "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/MassFormatter/unitString(fromKilograms:usedUnit:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMassFormatter(im)unitStringFromKilograms:usedUnit:"
  },
  "title" : "unitString(fromKilograms:usedUnit:)"
}
-->

# unitString(fromKilograms:usedUnit:)

Returns the unit string for the provided value.

```
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 [`MassFormatter.Unit`](/documentation/Foundation/MassFormatter/Unit) value that corresponds to the returned units.

## Return Value

A localized string representing the unit.

## Discussion

This method selects the correct unit based on the formatter’s locale, the magnitude of the value, and the [`isForPersonMassUse`](/documentation/Foundation/MassFormatter/isForPersonMassUse) property. The value, once converted into the appropriate unit, determines whether the unit string is plural or singular.

---

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)