在应用内购买:产品标识符的排序数组

时间:2018-07-21 02:56:29

标签: ios swift in-app-purchase storekit

我在RageProducts.swift中有以下非消耗性产品。

public struct RageProducts {

    // MARK: identifiers  product no consumible
    private static let s1 = "comic1" // name in itunnesconnect: Comic Vol 01
    private static let s2 = "comic2" // name in itunnesconnect: Comic Vol 02
    private static let s3 = "comic3" // name in itunnesconnect; Comic Vol 03
    private static let s4 = "comic4"
    private static let s5 = "comic5"
    private static let s6 = "comic6"
    private static let s7 = "comic7"
    private static let s8 = "comic8"
    private static let s9 = "comic9"
    private static let s10 = "comic10" // name in itunnesconnect: Comic Vol 10
    private static let s11 = "comic11"
    private static let s12 = "comic12"
    private static let s13 = "comic13"

    // MARK .-  Set identifiers

    private static let myproductsIdentifier:  Set<ProductIdentifier> = [RageProducts.s1,
                                                                             RageProducts.s2,
                                                                             RageProducts.s3,
                                                                             RageProducts.s4,
                                                                             RageProducts.s5,
                                                                             RageProducts.s6,
                                                                             RageProducts.s7,
                                                                             RageProducts.s8,
                                                                             RageProducts.s9,
                                                                             RageProducts.s10,
                                                                             RageProducts.s11,
                                                                             RageProducts.s12,
                                                                             RageProducts.s13]
//MARK :  Reference to IAPHelper 
    public static let store = IAPHelper(productIdentifiers: RageProducts.myproductosIdentifiers)

}

一切正常,除了按照它们在UITableview中显示的顺序,它不遵守在数组(Set <ProductIdentifier>)中输入的顺序

这向我显示:

Comic Vol 01
Comic Vol 10
Comic Vol 11
Comic Vol 12
Comic Vol 13
Comic Vol 02
Comic Vol 03
.
.
.
Comic Vol 09

正确的信息应该是:

Comic Vol 01
Comic Vol 02
Comic Vol 03
Comic Vol 04
Comic Vol 05
.
.
.
Comic Vol 13

是否可以根据输入的顺序对它们进行排序,或者如何解决此问题?

Screenshot of how products are displayed

2 个答案:

答案 0 :(得分:2)

尝试使用数组,而不是一个一个地声明

public struct RageProducts {

// MARK: identifiers  product no consumible
private static let arrayOfIdentifiers = ["comic1", "comic2", "comic3",
                                         "comic4","comic5", "comic6",
                                        "comic7","comic8","comic9",
                                        "comic10","comic11","comic12","comic13"]

// MARK .-  Set identifiers

private static let myproductsIdentifier:  Set<ProductIdentifier> = [RageProducts.arrayOfIdentifiers]
//MARK :  Reference to IAPHelper
public static let store = IAPHelper(productIdentifiers: RageProducts.myproductosIdentifiers) 
}

答案 1 :(得分:0)

尝试重命名产品:Comic Vol 1,Comic Vol 2,... Comic Vol 10,...