NSNumberFormatter maximumFractionDigits and maximumSignificantDigits bug

后端 未结 1 1512
失恋的感觉
失恋的感觉 2021-01-05 07:43

Is this a bug when using maximumFractionDigits and maximumSignificantDigits together on NSNumberForamtter on iOS 8?

NS         


        
相关标签:
1条回答
  • 2021-01-05 08:23

    It isn't a bug. From the docs:

    Note

    When a number formatter is configured to use significant digits, it ignores any minimum or maximum values used to set integer or fraction digits.

    https://developer.apple.com/documentation/foundation/nsnumberformatter/1417793-usessignificantdigits?language=objc

    Note: If either maximumSignificantDigits or minimumSignificantDigits is set to any value, then usesSignificantDigits is automatically set to true. This contradicts the docs for maximumSignificantDigits and minimumSignificantDigits which says:

    You must set the usesSignificantDigits property to true in order for this property to affect formatting behavior.

    You don't need to set usesSignificantDigits to true, it will set itself to true.

    0 讨论(0)
提交回复
热议问题