I have a string already formatted, I would like to convert it to float and then to a number formatted for currency.
input output 1234.1 1234.1 or 1234.1
input output 1.234.10 1.234.10
I have a string already formatted, I would like to convert it to float and then to a number formatted for currency.
input output 1234.1 1234.1 or 1234.1
input output 1.234.10 1.234.10
I use this way:
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
NSLocale *localizableIdentifier = [[NSLocale alloc] initWithLocaleIdentifier:@"pt_BR"];
[formatter setLocale:localizableIdentifier];
float money = 300.23f;
NSNumber *meuDinheiro = [NSNumber numberWithFloat:money];
NSString *newString = [formatter stringFromNumber:meuDinheiro];
NSLog(@"Você me deve: %@", newString);