-(NSString *)convertCurrency:(NSString *)textFieldString{
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle: NSNumberFormatterNoStyle];
[numberFormatter setGroupingSize:3];
[numberFormatter setGroupingSeparator:@","];
[numberFormatter setUsesGroupingSeparator:YES];
[numberFormatter setMaximumIntegerDigits:20];
number= [NSNumber numberWithInt:[textFieldString intValue]];
NSString *numberString = [NSString stringWithFormat:@"$%@",[numberFormatter stringForObjectValue:number]];
return numberString;
}
當我發送的textfield字符串值是發送10000000000只返回$ 2,147,483,647但我只想要$ 10,000,000,000。如何解決這個問題。如何克服2,147,483,647問題NSNumberFormatter
使用更大的數據類型。 – Raptor
@ShivanRaptor更大的數據類型意味着longlongvalue我也嘗試該方法 – Ben10