我使用以下函数将数字从英语转换为阿拉伯语:
-(NSString *)convertEnNumberToArabic:(NSString *) number{
NSString *text;
NSDecimalNumber *someNumber = [NSDecimalNumber decimalNumberWithString:number];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
NSLocale *gbLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"ar"];
[formatter setLocale:gbLocale];
text = [formatter stringFromNumber:someNumber];
return text;
}
NSString *convertedCharge = [self convertEnNumberToArabic:[NSString stringWithFormat:@"%f", [self deliveryCharge]]];
在我获得阿拉伯数字后,如果我想将其转换为浮点数,则返回英语如下:
CGFloat floatCharge = (CGFloat)[convertedCharge floatValue];
所以floatcharge再次以英文返回值,我该如何解决这个问题呢?我需要将值作为cgfloats