对于分析和收集数据,我想以美元的价格获得SKProduct的价格.
@H_301_2@我用来向用户显示价格的基本代码是:
这是我改变尝试这个:
_priceFormatter = [[NSNumberFormatter alloc] init]; [_priceFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; [_priceFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; [_priceFormatter setLocale:inAppProduct.priceLocale]; inAppItemString = [_priceFormatter stringFromNumber:inAppProduct.price];@H_301_2@此代码为我提供了用户应使用当地硬币支付的实际价格 @H_301_2@我尝试将本地设置为en_US,但我得到了与以前相同的价格,以及$:)
这是我改变尝试这个:
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; [_priceFormatter setLocale:usLocale];@H_301_2@知道如何以美元获得价格吗?
解决方法
您可能想尝试以下方法:
NSLocale *priceLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];@H_301_2@参考:Is there a simple way to format currency into string in iOS?