Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the new iOS9/OSX10.11 NSNumberFormatterStyle enum values mean?

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,
};
like image 538
Ky. Avatar asked Feb 09 '23 21:02

Ky.


1 Answers

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:

enter image description here

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.

  • 1st Foo
  • 2nd Bar
  • ...
  • 42nd Foo Bar
like image 132
mangerlahn Avatar answered May 16 '23 07:05

mangerlahn