iOS – 使用NSNumberFormatter显示不分美元的货币

我可以使用NSNUmberFormatter将一个特定的NSNumber转换成货币.它显示$符号,用“,”等分隔的数字
但我不想显示分.
例如它显示$537,335.32
我只想显示$536,335
我正在写下面的代码
NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];

NSDictionary* tempDict = [self.displayDict objectForKey:kConservative];
conservativeHP.text = [currencyFormatter stringFromNumber:[tempDict objectForKey:kHomePrice]];

我应该如何创建NSNumberFormatter或做某事,使结果不会有“小数”

解决方法

在将数字添加到格式化程序之前,将其更改为int以避免小数,如下所示:
float myValue = 543.32;

NSNumber myNumber = [NSNumber numberWithInt: (int)myValue)];

你会摆脱小数部分!

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...