Is it possible to derive currency symbol from currency code?

前端 未结 5 1679
鱼传尺愫
鱼传尺愫 2021-02-04 19:04

My iPhone app formats an NSDecimalNumber as a currency using setCurrencyCode, however another screen displays just the currency symbol. Rather than storing both the currency cod

5条回答
  •  眼角桃花
    2021-02-04 19:22

    You can get number with currency symbol from number with currency code.

    This is the way I do:

        NSString *currencyCode = @"HKD";
        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        [numberFormatter setCurrencyCode:currencyCode];
        [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
    
        cell.amountLabel.text = [numberFormatter stringFromNumber: expense.exAmount];
    

提交回复
热议问题