<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/UnitConverter",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSUnitConverter"
  },
  "title" : "UnitConverter"
}
-->

# UnitConverter

An abstract class that provides a description of how to convert a unit to and from the base unit of its dimension.

```
class UnitConverter
```

## Overview

For units that can be converted by a scale factor or linear equation, use the concrete subclass [`UnitConverterLinear`](/documentation/Foundation/UnitConverterLinear).

### Subclassing Notes

[`UnitConverter`](/documentation/Foundation/UnitConverter) is an abstract class that is intended for subclassing. You can implement your own subclass of [`UnitConverter`](/documentation/Foundation/UnitConverter) to convert between units according to any desired mapping function. For example, units may be converted using a logarithmic, exponential, or quantile scale.

#### Methods to Override

All subclasses must fully implement the following methods:

- [`baseUnitValue(fromValue:)`](/documentation/Foundation/UnitConverter/baseUnitValue(fromValue:))
- [`value(fromBaseUnitValue:)`](/documentation/Foundation/UnitConverter/value(fromBaseUnitValue:))

#### Alternatives to Subclassing

As stated above, most physical units can be converted using a linear equation with [`UnitConverterLinear`](/documentation/Foundation/UnitConverterLinear). You should only create a custom subclass of [`UnitConverter`](/documentation/Foundation/UnitConverter) for units that cannot be converted in this way.

## Topics

### Converting Between Units

[`-  baseUnitValueFromValue:`](/documentation/Foundation/UnitConverter/baseUnitValue(fromValue:))

For a given unit, returns the specified value of that unit in terms of the base unit of its dimension.

[`-  valueFromBaseUnitValue:`](/documentation/Foundation/UnitConverter/value(fromBaseUnitValue:))

For a given unit, returns the specified value of the base unit in terms of that unit.

## Relationships

### Inherited By

[`UnitConverterLinear`](/documentation/Foundation/UnitConverterLinear)

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)