photo of imac near macbook

Display currency in SwiftUI

To display Currency properly formatted in SwiftUI you have to do the following Define the value of Currency as a double @State private var unitPrice = 0.0 For a TextField, write this: TextField("Unit Price: ", value: $unitPrice , format: .currency(code: Locale.current.currency?.identifier ?? "USD")) For a Text, write this: Text(unitPrice, format: .currency(code: Locale.current.currency?.identifier ?? "USD")) Here's how the entire code looks...Read More