SwiftUI: Format Currency the Easy Way
<p>Displaying (or accepting) a number as currency in a Text field is a common thing that we want to do in SwiftUI. In the example below, we set a State variable for holding the amount that we want to display, and use the format option to convert it to the users local currency. We are setting a fall back to “USD” (United States Dollars) just in case the user has not set a currency, or the currency is not available.</p>
<p>Before we get lost in all the cool things we are about to learn, please take a couple seconds to follow me and clap for the article so that we can help more people learn about this useful content.</p>
<p>Note that using the Locale.current option will automatically format the number you passed in to match the currency set on the users device. It DOES NOT automatically convert the value that was passed in to the users preferred currency.</p>
<p><a href="https://medium.com/@jpmtech/swiftui-format-currency-the-easy-way-ec6c604ca299"><strong>Learn More</strong></a></p>