Skip to content

Commit

Permalink
Remove localizedIntroductoryPrice, introductoryPrice
Browse files Browse the repository at this point in the history
  • Loading branch information
bizz84 committed Dec 20, 2017
1 parent 8fe13ff commit 96a5956
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions SwiftyStoreKit/SKProduct+LocalizedPrice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,13 @@ import StoreKit
public extension SKProduct {

public var localizedPrice: String? {
return formattedPrice(price: price, locale: priceLocale)
return priceFormatter(locale: priceLocale).string(from: price)
}

@available(iOS 11.2, OSX 10.13.2, tvOS 11.2, *)
public var localizedIntroductoryPrice: String? {
guard let introductoryPrice = introductoryPrice else {
return nil
}
return formattedPrice(price: introductoryPrice.price, locale: introductoryPrice.priceLocale)
}

private func formattedPrice(price: NSDecimalNumber, locale: Locale) -> String? {
let numberFormatter = NumberFormatter()
numberFormatter.locale = locale
numberFormatter.numberStyle = .currency
return numberFormatter.string(from: price)

private func priceFormatter(locale: Locale) -> NumberFormatter {
let formatter = NumberFormatter()
formatter.locale = locale
formatter.numberStyle = .currency
return formatter
}
}

0 comments on commit 96a5956

Please sign in to comment.