如何在iphone中将货币格式的字符串设置为普通数字格式?我有一个货币格式的数字,例如“10,000卢比”或"$ 100,000“.now我将它作为字符串保存在我的数据库中,作为一个普通数字格式的字符串,如"10000”或"1000000“..so如何将其转换为此格式。因为只有使用后一个字符串,我才能使用字符串intValue进行计算
发布于 2011-09-17 06:18:32
您是否正在使用NSNumberFormatter根据区域设置设置货币样式?如果是这样,只需将其提取为NSNumber对象:
NSDecimalNumber *currencyAmount = [NSDecimalNumber decimalNumberWithString:@"100.00"];
NSNumberFormatter *currency = [[NSNumberFormatter alloc] init];
[currency setNumberStyle:NSNumberFormatterCurrencyStyle];
[currency setLocale:yourLocale];
NSString *yourstring = [NSString stringWithFormat:@"%@", [currency stringFromNumber:someAmount];
NSNumber* number = [currency numberFromString:yourString];
https://stackoverflow.com/questions/7450783
复制相似问题