iOS内购IAP获取货币和符号
2019-06-25 本文已影响0人
jiang12306
1.获取货币符号和金额
在内购查询商品回调方法中获取
<code>
-(void)productsRequest:(SKProductsRequest*)request didReceiveResponse:(SKProductsResponse*)response {
for(SKProduct* subProductin products) {
NSString* currencySymbol = [subProduct.priceLocale objectForKey:NSLocaleCurrencySymbol];//这里获取到的就是货币符号,例如:¥、$等等
NSNumberFormatter*numberFormatter = [[NSNumberFormatter alloc]init];
[numberFormattersetFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormattersetNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormattersetLocale:subProduct.priceLocale];
NSString* formattedPrice = [numberFormatterstringFromNumber:subProduct.price];//这里获取到的就是货币符合和金额,例如:¥6.00,$0.99
break;
}
}
</code>