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
currencyCodeThe ISO 4217 currency code (e.g., “USD”). If nil, uses the locale’s default currency.
localeIdentifierThe locale identifier (e.g., “en_US”). Defaults to the current locale.
maxFractionDigitsThe maximum number of fraction digits. Defaults to 2.
minFractionDigitsThe minimum number of fraction digits. Defaults to 0.
currencyDecimalSeparatorThe decimal separator to use. If nil, uses the locale’s default.
currencyGroupingSeparatorThe 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 }