Objective c iOS 13用户的NSNumberFormatter忽略设置舍入增量

Objective c iOS 13用户的NSNumberFormatter忽略设置舍入增量,objective-c,nsnumber,ios13,nsnumberformatter,Objective C,Nsnumber,Ios13,Nsnumberformatter,自2012年以来,下面的代码返回了“0.70欧元”,这很好,因为这正是预期的结果 NSLocale *locale = [NSLocale currentLocale]; NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init]; [currencyStyle setLocale:locale]; [currencyStyle setNumberStyle:NSNumberFormatterCurrencyStyle]

自2012年以来,下面的代码返回了“0.70欧元”,这很好,因为这正是预期的结果

NSLocale *locale = [NSLocale currentLocale];
NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init];
[currencyStyle setLocale:locale];
[currencyStyle setNumberStyle:NSNumberFormatterCurrencyStyle];
[currencyStyle setFormatterBehavior:NSNumberFormatterBehavior10_4];
[currencyStyle setCurrencySymbol:[countriesCurrency objectForKey:currency]];
[currencyStyle setRoundingIncrement:[NSNumber numberWithFloat:0.01]];
但由于iOS 13(应用程序构建使用xCode 10.3,只有iPhone上安装了iOS 13的用户才能从AppStore下载应用程序。iOS 13.0和13.1 beta上的构建抛出xCode 11也是如此)同样的代码返回“0699998435378074欧元”

经过午夜的快速调查发现,如果

po [currencyStyle stringFromNumber:[NSNumber numberWithFloat:0.70]]
然后结果将是“0.7欧元”——好得多,但仍不完全符合预期(“0.70欧元”)

有没有办法让setRoundingIncrement再次伟大

[更新]:
重写相同的代码以swift解决问题,但这听起来像是临时解决方案,因为所有rest应用程序都在Obj-C中。

老实说,我不确定舍入增量到底是什么,因为文档中没有提到它。你确定。设置
minimumFractionDigits=2
maximumFractionDigits=2
,难道还不够吗?@Sulthan刚刚尝试过同样的方法result@Sulthan不应为货币格式化程序设置小数位数。并非所有货币都使用相同的位数。@YauheniShauchenka您在未设置
的情况下设置
.minimumFractionDigits
失败。舍入增量
?然而,在设计上,使用浮点数作为货币是错误的。使用浮动作为货币的浮动指针数字在设计上是错误的。“至少用双打试试吧!”阿明尼姆·阿瓦德,顺便说一句,我们刚刚试过,面对的是用swift编写的同样的代码,它工作得很好。浮动在这里不是问题,因为我们只需要逗号后的2位数字,这就是价格。老实说,我不确定舍入增量到底是什么,因为文档中没有提到它。你确定。设置
minimumFractionDigits=2
maximumFractionDigits=2
,难道还不够吗?@Sulthan刚刚尝试过同样的方法result@Sulthan不应为货币格式化程序设置小数位数。并非所有货币都使用相同的位数。@YauheniShauchenka您在未设置
的情况下设置
.minimumFractionDigits
失败。舍入增量
?然而,在设计上,使用浮点数作为货币是错误的。使用浮动作为货币的浮动指针数字在设计上是错误的。“至少用双打试试吧!”阿明尼姆·阿瓦德,顺便说一句,我们刚刚试过,面对的是用swift编写的同样的代码,它工作得很好。浮动在这里不是问题,因为我们只需要逗号后的2位数字,这就是价格。
currencyStyle.usesSignificantDigits = YES;