Target: Generic input field for any numerical value with the associated unit. The metadata for this input field is stored in a database and includes:
What the value should represent (text).
Which unit applies to it (text)
For this I try to write the following function:
func getMeasurment(value: Double, unit: String) -> Measurement<Unit> {
switch(unit) {
case "UnitArea.squareKilometers":
let result = Measurement(value: value, unit: UnitArea.squareKilometers)
return result
case "...":
....
}
Of course I get a compiler error, is there a possible solution for this task?
Please excuse my question, but I am absolute beginner in Swift ...