You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example used to get product details the approach uses the following to get price:
let priceString = NSNumberFormatter.localizedStringFromNumber(product.price ?? 0, numberStyle: .CurrencyStyle)
The problem I see with this is that it's using the device's region setting to set currency. However, it is possible that the device's region settings are not aligned with the locale that Apple is sending with the product description. In that case the above approach will incorrectly present a currency symbol for the amount given. For example if region is set to France and Apple sends the amount in USD, the code above would put in a Euro symbol but with a USD amount.
Rather than the above I think we should look at the locale of the price Apple sends. This will ensure that the currency symbol always matches the amount. Something like this:
let numberFormatter = NSNumberFormatter()
numberFormatter.locale = product.priceLocale
numberFormatter.numberStyle = .CurrencyStyle
let priceString = numberFormatter.stringFromNumber(product.price ?? 0)!
The text was updated successfully, but these errors were encountered:
C6silver
changed the title
Produce Price Example Should be Changed
Product Price Example Should be Changed
Aug 26, 2016
In the example used to get product details the approach uses the following to get price:
let priceString = NSNumberFormatter.localizedStringFromNumber(product.price ?? 0, numberStyle: .CurrencyStyle)
The problem I see with this is that it's using the device's region setting to set currency. However, it is possible that the device's region settings are not aligned with the locale that Apple is sending with the product description. In that case the above approach will incorrectly present a currency symbol for the amount given. For example if region is set to France and Apple sends the amount in USD, the code above would put in a Euro symbol but with a USD amount.
Rather than the above I think we should look at the locale of the price Apple sends. This will ensure that the currency symbol always matches the amount. Something like this:
The text was updated successfully, but these errors were encountered: