I want to format a Double value such as -24.5
into a currency formatted string like -$24.50
. How would I do that in Swift?
I followed this post, but it ends up formatting as $-24.50
(negative sign after the $), which is not what I want.
Is there a more elegant solution to achieve this, besides something like this?
if value < 0 {
return String(format: "-$%.02f", -value)
} else {
return String(format: "$%.02f", value)
}