NumberFormatter
public extension NumberFormatter
-
init(currencyCode:
localeIdentifier: maxFractionDigits: minFractionDigits: currencyDecimalSeparator: currencyGroupingSeparator: ) Convenience initializer for creating a currency formatter with custom options.
Declaration
Swift
convenience init( currencyCode: String? = nil, localeIdentifier: String = Locale.current.identifier, maxFractionDigits: Int = 2, minFractionDigits: Int = 0, currencyDecimalSeparator: String? = nil, currencyGroupingSeparator: String? = nil )
Parameters
currencyCode
The ISO 4217 currency code (e.g., “USD”). If nil, uses the locale’s default currency.
localeIdentifier
The locale identifier (e.g., “en_US”). Defaults to the current locale.
maxFractionDigits
The maximum number of fraction digits. Defaults to 2.
minFractionDigits
The minimum number of fraction digits. Defaults to 0.
currencyDecimalSeparator
The decimal separator to use. If nil, uses the locale’s default.
currencyGroupingSeparator
The grouping separator to use. If nil, uses the locale’s default.
-
Returns a default configured currency formatter instance using the current locale and standard settings.
Declaration
Swift
static var currencyDefault: NumberFormatter { get }