NSNumberFormatter numberFromString不返回货币字符串中的数字

时间:2012-09-18 15:45:37

标签: ios5 nsnumberformatter

numberFormatter = [[NSNumberFormatter alloc] init];
numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;    
NSLog(_priceTF.text);
NSNumber *price = [numberFormatter numberFromString:_priceTF.text];
NSLog([price stringValue]);

控制台输出:25 kr

P.S。 :价格是零。

1 个答案:

答案 0 :(得分:0)

目前,我得到了NSNumber(但这很奇怪):

NSString *priceNoCurrency = [_priceTF.text stringByReplacingOccurrencesOfString:numberFormatter.currencySymbol withString:@""];
NSNumber *price = @(priceNoCurrency.integerValue);