Skip to content

Commit eada88c

Browse files
authored
Merge pull request #320 from bizz84/feature/remove-localized-introductory-price
Remove localizedIntroductoryPrice (restore Xcode 8 compatibility)
2 parents 8fe13ff + 423d2ea commit eada88c

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.11.2](https://github.com/bizz84/SwiftyStoreKit/releases/tag/0.11.2) Remove `SKProduct.localizedIntroductoryPrice`
6+
7+
* Remove `localizedIntroductoryPrice` ([#320](https://github.com/bizz84/SwiftyStoreKit/pull/320), see [#319](https://github.com/bizz84/SwiftyStoreKit/issues/319), [#318](https://github.com/bizz84/SwiftyStoreKit/pull/318), [#315](https://github.com/bizz84/SwiftyStoreKit/pull/315))
8+
59
## [0.11.1](https://github.com/bizz84/SwiftyStoreKit/releases/tag/0.11.1) Add `PaymentTransaction.transactionDate` and `SKProduct.localizedIntroductoryPrice`
610

711
* Add `transactionDate` to `PaymentTransaction` ([#316](https://github.com/bizz84/SwiftyStoreKit/pull/316), see [#312](https://github.com/bizz84/SwiftyStoreKit/issues/312)).

SwiftyStoreKit/SKProduct+LocalizedPrice.swift

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,13 @@ import StoreKit
2828
public extension SKProduct {
2929

3030
public var localizedPrice: String? {
31-
return formattedPrice(price: price, locale: priceLocale)
31+
return priceFormatter(locale: priceLocale).string(from: price)
3232
}
33-
34-
@available(iOS 11.2, OSX 10.13.2, tvOS 11.2, *)
35-
public var localizedIntroductoryPrice: String? {
36-
guard let introductoryPrice = introductoryPrice else {
37-
return nil
38-
}
39-
return formattedPrice(price: introductoryPrice.price, locale: introductoryPrice.priceLocale)
40-
}
41-
42-
private func formattedPrice(price: NSDecimalNumber, locale: Locale) -> String? {
43-
let numberFormatter = NumberFormatter()
44-
numberFormatter.locale = locale
45-
numberFormatter.numberStyle = .currency
46-
return numberFormatter.string(from: price)
33+
34+
private func priceFormatter(locale: Locale) -> NumberFormatter {
35+
let formatter = NumberFormatter()
36+
formatter.locale = locale
37+
formatter.numberStyle = .currency
38+
return formatter
4739
}
4840
}

0 commit comments

Comments
 (0)