Find locale currency for iphone programmatically

前端 未结 7 508
攒了一身酷
攒了一身酷 2020-12-02 05:20

I want to find out the currency locale on user\'s iphone programmatically. That means, if user is in US Store, the currency locale should be USD, for Australia, it should be

7条回答
  •  星月不相逢
    2020-12-02 06:05

    Here is an example in Swift 5:

    let formatter = NumberFormatter()
    formatter.formatterBehavior = .behavior10_4
    formatter.numberStyle = .currency
    formatter.locale = product.priceLocale
    print(formatter.string(from: products![0].price)
    

提交回复
热议问题