How to access the price of a product in SKPayment?

前端 未结 5 1651
無奈伤痛
無奈伤痛 2020-12-23 02:41

I am having an In-App-Purchase for an iPhone app.

I want to display the price in the users local currency in a UILabel. For this I need the price & currency in a

5条回答
  •  一生所求
    2020-12-23 02:58

    Here's the Swift version of the above answer using an extension:

    extension SKProduct {
      func priceAsString() -> String {
        let formatter = NumberFormatter()
        formatter.formatterBehavior = .behavior10_4
        formatter.numberStyle = .currency
        formatter.locale = self.priceLocale
        return formatter.string(from: self.price)! as String
      }
    }
    

提交回复
热议问题