我有這些數字格式:數字格式與NSNumberFormatter已經有小數和千個分隔符
100000,459
100000459
100.000
100.000,59
100.000.000,39
數字變成爲用戶輸入的值給它。對於每個增加的值,我需要使用NSNumberFormatter重新格式化數字。問題是這個數字已經有了。並且格式化程序似乎沒有正確處理這些內容。它是這樣出現的:
100 000,00
100 000 459,00
100,00
100,00
100,00
例如,我想100000459變成100000459。
我現在使用的代碼:
NSNumber *amount = [NSNumber numberWithInt:[string intValue]];
NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"nb_NO"];
[currencyFormatter setLocale:locale];
NSString *commaString = [currencyFormatter stringForObjectValue:amount];
如何I格式已經格式化的數字?
感謝您的回覆!不幸的是它對結果沒有任何影響。仍然錯誤。 – doh 2010-12-10 11:28:32