IPhone, how do I remove a localized currency format and create a double?

I found this great question / answer on how to localize a string with current user currency settings ... localize-currency-for-iphone

This code is used ...

NSDecimalNumber *someAmount = [NSDecimalNumber decimalNumberWithString:@"5.00"];
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
NSLog(@"%@", [currencyFormatter stringFromNumber:someAmount]);

However, do I need to convert this to double so that I can store it in my database?

EDIT: This must be read. I need to convert this back to a string without generating a currency, and then convert it to double.

+3
source share
1 answer

Take the line and call the reverse method:

NSNumber* number = [currencyFormatter numberFromString:string];
+3
source

Source: https://habr.com/ru/post/1770885/


All Articles