in-app-purchase price locale number formatter (what is behaviour10_4)

Viewed 61

Working on price localisation for IAP and while the below codes both work the same (simulator) I would like to know what is this behavior10_4?

Apple's doc doesn't say much and googling and SO also don't have much info about it. https://developer.apple.com/documentation/foundation/dateformatter/behavior/behavior10_4

extension IAPHelper {
    // https://stackoverflow.com/a/42009726/14414215
    static func priceFor(_ product: SKProduct) -> String? {
        let formatter = NumberFormatter()
        formatter.formatterBehavior = .behavior10_4
        formatter.numberStyle = .currency
        formatter.locale = product.priceLocale
        return formatter.string(from: product.price)
    }
    
    // Adapted from https://developer.apple.com/documentation/storekit/skproduct/1506094-price
    static func localizedPrice(_ product: SKProduct) -> String? {
        let formatter = NumberFormatter()
        formatter.numberStyle = .currency
        formatter.locale = product.priceLocale
        return formatter.string(from: product.price)
    }

}


print("Currency1:\(IAPHelper.priceFor(p) ?? "")")        // USD 0.99
print("Currency2:\(IAPHelper.localizedPrice(p) ?? "")")  // USD 0.99
0 Answers
Related