objective-c – 如何在Objective C中显示波斯文本中的数字,如125显示“一百二十五”?

NSString *numberWord;
NSNumber *numberValue = [NSNumber numberWithInt:125];
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterSpellOutStyle];
numberWord = [numberFormatter stringFromNumber:numberValue];

//我要展示“صدوبیستوپنج”

最佳答案 您需要将数字格式化程序的语言环境设置为波斯语区域设置.

NSNumber *numberValue = @(125);
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterSpellOutStyle];
[numberFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"fa"]];
NSString *numberWord = [numberFormatter stringFromNumber:numberValue];

这将输出:

صد و بیست و پنج

点赞