我有一个价格,我需要根据所选货币进行转换。intValue缺少小数
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"currency.plist"];
NSDictionary *plistDictionary = [[NSDictionary dictionaryWithContentsOfFile:finalPath] retain];
int price = [price intValue];
int currencyValue = [[plistDictionary valueForKey:@"EUR"] intValue];
int convertedCurrency = (price/currencyValue);
price
是NSNumber
和valueForKey
也从plist文件中我有一个转换率设置一个号码。
我遇到的问题是我的price
缺少小数。每当我从价格中获得intValue时,它就会向上或向下四舍五入。我从plist得到的汇率也存在同样的问题。
我已经调查过NSNumberFormatter
,但它不会让我为NSNumberFormatter。有什么建议吗?
查找“整数”是什么意思,然后看看你是否理解这个问题。 – 2010-12-13 05:35:34