我有一個價格,我需要根據所選貨幣進行轉換。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