通貨を Word 形式に変換する関数を作成しますが、私の問題は、テキスト フィールドの値を100000に設定すると、インド形式で 1000 万必要ですが、10 万が得られるので、そのための解決策です。
NSString *str1 = txtAmount.text;
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle: NSNumberFormatterSpellOutStyle];
NSString *localeStr = [appDel.countryCodeDict valueForKey:appDel.selectedCountry];
if ([appDel.selectedCountry isEqualToString:@"France"]) {
localeStr = @"fr";
}
if ([appDel.selectedCountry isEqualToString:@"Germany"]) {
localeStr = @"de";
}
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:localeStr];
[formatter setLocale:usLocale];
[formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
NSArray *valueArr=[str1 componentsSeparatedByString:@"."];
[formatter setNumberStyle: NSNumberFormatterSpellOutStyle];
NSString *firstStr = [valueArr objectAtIndex:0];
NSString *seconfStr = [valueArr lastObject];
if (valueArr.count==2 && ![seconfStr isEqualToString:@""]) {
double firstAmt = [firstStr doubleValue];
NSString *convertStr = [formatter stringFromNumber:[NSNumber numberWithDouble:firstAmt]];
double secondAmt = [seconfStr doubleValue];
NSString *convertStr1 = [formatter stringFromNumber:[NSNumber numberWithDouble:secondAmt]];
NSString *finalStr = [convertStr stringByAppendingFormat:@" %@ %@ %@",appDel.firstCurrencystr,convertStr1,appDel.secondCurrencystr];
NSLog(@"%@",finalStr);
NSString *firstCapChar = [[finalStr substringToIndex:1] capitalizedString];
tempStr = [finalStr stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:firstCapChar];
}else{
double firstAmt = [firstStr doubleValue];
NSString *convertStr = [formatter stringFromNumber:[NSNumber numberWithDouble:firstAmt]];
convertStr = [convertStr stringByAppendingFormat:@" %@",appDel.firstCurrencystr];
NSString *firstCapChar = [[convertStr substringToIndex:1] capitalizedString];
tempStr = [convertStr stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:firstCapChar];
}
appDel.lblAmountView.lblAmount.text = tempStr;
それについての考え。