The iOS and OS X NSNumberFormatterStyle
enum gained 4 new values with the new iOS 9 and OS X 10.11 SDK! They sound cool and useful, but Apple's documentation and even Google had nothing to say about them!
What do these new values do when passed to a formula, and how are they different than the old values?
In iOS 9.0 or OS X 10.11 〉Frameworks 〉Foundation 〉NSNumberFormatter.h lines 46-57:
typedef NS_ENUM(NSUInteger, NSNumberFormatterStyle) {
NSNumberFormatterNoStyle = kCFNumberFormatterNoStyle,
NSNumberFormatterDecimalStyle = kCFNumberFormatterDecimalStyle,
NSNumberFormatterCurrencyStyle = kCFNumberFormatterCurrencyStyle,
NSNumberFormatterPercentStyle = kCFNumberFormatterPercentStyle,
NSNumberFormatterScientificStyle = kCFNumberFormatterScientificStyle,
NSNumberFormatterSpellOutStyle = kCFNumberFormatterSpellOutStyle,
NSNumberFormatterOrdinalStyle NS_ENUM_AVAILABLE(10_11, 9_0) = kCFNumberFormatterOrdinalStyle,
NSNumberFormatterCurrencyISOCodeStyle NS_ENUM_AVAILABLE(10_11, 9_0) = kCFNumberFormatterCurrencyISOCodeStyle,
NSNumberFormatterCurrencyPluralStyle NS_ENUM_AVAILABLE(10_11, 9_0) = kCFNumberFormatterCurrencyPluralStyle,
NSNumberFormatterCurrencyAccountingStyle NS_ENUM_AVAILABLE(10_11, 9_0) = kCFNumberFormatterCurrencyAccountingStyle,
};
Take a look at this year's Session 227 - What's New in Internationalization (video; text)
In the video it is explained at 18:34 - here is a screenshot of this particular slide:
In addition to the existing NSNumberFormatterStyles
Apple introduced four new styles in iOS 9 and OS X 10.11.
In addition to the already existing 'currency style, we now have 'currency ISO code style, as well 'currency plural style' and 'currency accounting style.' Interestingly here for 'currency accounting style, if you pass it a negative number, it presents it surrounded by parentheses. This is common in accounting circles.
To see what these currency styles look like, take a look ate the picture above. The ordinal style can be used for ordered lists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With