I've got a string with currency having the format of the local currency. For example 10000 Danish kroner will be (10.000,00) When cast to double value it just read it 10. I tried this snippet
NSString * locale ;
if(locale == nil || [locale isEqualToString:@""]){
locale = @"da_DK";
}
NSLocale *priceLocale = [[NSLocale alloc] initWithLocaleIdentifier:locale] ;
[NSDecimalNumber decimalNumberWithString:actualCash locale:priceLocale].doubleValue
But it didn't work
any idea will be appreciated.
Use NSNumberFormatter
directly:
NSNumberFormatter* formatter = [NSNumberFormatter new];
formatter.numberStyle = NSNumberFormatterDecimalStyle;
formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"da_DK"];
NSNumber* result = [formatter numberFromString:@"10.000,00"];