【问题标题】:Is that possible to print NSLocale currency in ios?是否可以在 ios 中打印 NSLocale 货币?
【发布时间】:2013-07-27 19:04:45
【问题描述】:

我正在寻找可以显示 NSLocale 货币格式的代码。

我使用了下面的代码

    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init] ;
        [formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
        [formatter setLocale:skProduct.priceLocale];
        NSLog(@"formatter%@",formatter);

        NSLog(@"%@",skProduct.priceLocale);  ////  i want to print NSLocale value

      NSString*  currencyString = [formatter stringFromNumber:skProduct.price];
  NSLog(@"currencyString price %@",currencyString);

如何根据 NSLocale 显示确切的价格金额,当我尝试 NSLog(@"%@",skProduct.priceLocale);它显示像一些内存位置.. 请帮帮我

【问题讨论】:

    标签: ios objective-c currency nslocale


    【解决方案1】:

    试试这个:

      NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init] ;
      [formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
      NSString*  currencyString = [formatter currencySymbol];
      NSLog(@"currencyString %@",currencyString);
    

    【讨论】:

    • 没有老板,我想转换价格金额而不是货币符号或代码,我想要 59.8 卢比到 1 美元的转换
    • 如果我像“skProduct.price”一样打印,那么它将以 INR 格式(印度卢比)而不是当前语言环境国家/地区打印
    • @Navi,我认为在这种情况下,您需要获取货币汇率并手动转换。
    • 我已经开发了该代码,但我需要知道苹果方面的任何可能?
    • @Navi 没有,NSLocale 没有这个功能,见文档developer.apple.com/library/mac/#documentation/Cocoa/Reference/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-23
    • 2011-04-30
    • 2011-04-30
    • 2015-04-15
    • 2011-01-23
    • 1970-01-01
    • 2012-01-22
    相关资源
    最近更新 更多