Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product Price Example Should be Changed #73

Closed
C6silver opened this issue Aug 26, 2016 · 2 comments
Closed

Product Price Example Should be Changed #73

C6silver opened this issue Aug 26, 2016 · 2 comments

Comments

@C6silver
Copy link

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)!
@C6silver C6silver changed the title Produce Price Example Should be Changed Product Price Example Should be Changed Aug 26, 2016
@Esqarrouth
Copy link

#71

I've also had this issue, I think you should send a pull request for this

@bizz84
Copy link
Owner

bizz84 commented Aug 28, 2016

Thank you for suggesting the fix.

Updated: e479b88

@bizz84 bizz84 closed this as completed Aug 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants