I am looking for a simple way to convert a Hex to decimal in Swift 3. For example, this code converts binary to decimal without any problems.
func convertToDecimal(binaryVal: String) -> String { var result: Int = 0 for num in binaryVal { switch num { case "0": result = result * 2 case "1": result = result * 2 + 1 default: return "Error" } } return "\(result)" } Maybe there is same workaround but only for Hex to decimal?