---
title: "string(fromValue:unit:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/energyformatter/string(fromvalue:unit:)"
---

# string(fromValue:unit:)

Returns a properly formatted energy string for the given value and unit.

## Declaration

```swift
func string(fromValue value: Double, unit: EnergyFormatter.Unit) -> String
```

## Parameters

- `value`: The energy value in the given unit.
- `unit`: The unit used in the resulting energy string.

## Return Value

Return Value A localized string that combines the provided value and unit.

## See Also

### Formatting Energy Strings

- [isForFoodEnergyUse](foundation/energyformatter/isforfoodenergyuse.md)
- [getObjectValue(_:for:errorDescription:)](foundation/energyformatter/getobjectvalue(_:for:errordescription:).md)
- [numberFormatter](foundation/energyformatter/numberformatter.md)
- [string(fromJoules:)](foundation/energyformatter/string(fromjoules:).md)
- [unitString(fromJoules:usedUnit:)](foundation/energyformatter/unitstring(fromjoules:usedunit:).md)
- [unitString(fromValue:unit:)](foundation/energyformatter/unitstring(fromvalue:unit:).md)
- [unitStyle](foundation/energyformatter/unitstyle.md)
