Looking for a Plug In or SwiftUI Kit were I can change measurements from Imperial to Metric or vice versa.
I don't have any problems with writing code for it, but thought I would ask before I embark on the task.
Thanks!
Looking for a Plug In or SwiftUI Kit were I can change measurements from Imperial to Metric or vice versa.
I don't have any problems with writing code for it, but thought I would ask before I embark on the task.
Thanks!
The Foundation framework has built-in support for measurements and conversions.
Here are some examples of how you can use the Measurement
type and convert between different units:
// Yards to Metres
let yardsValue = Measurement(value: 50, unit: UnitLength.yards)
let metresValue = yardsValue.converted(to: .meters)
// Pints to Litres
let pintsValue = Measurement(value: 10, unit: UnitVolume.pints)
let litresValue = pintsValue.converted(to: .liters)
// Pounds to Kilograms
let poundsValue = Measurement(value: 100, unit: UnitMass.pounds)
let kilogramsValue = poundsValue.converted(to: .kilograms)
thanks!