Find locale currency for iphone programmatically

前端 未结 7 504
攒了一身酷
攒了一身酷 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 05:59

    Matthias Bauch answer in swift:

    var formatter = NSNumberFormatter()
        formatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
        formatter.locale = product!.priceLocale
    var currencyString = "\(formatter.stringFromNumber(product!.price)!)"
    

提交回复
热议问题