我試圖在應用程序購買中實現storekit。下面的硬編碼值工作得很好:Swift3 Storekit - 將字符串數組轉換爲Set <ProductIdentifier>
我的全局結構:
static var productIdentifiers: Set<ProductIdentifier> = ["com.app.myIAP"]
static var store = IAPHelper(productIds: Globals.productIdentifiers)
在我的功能:
Globals.store = IAPHelper(productIds: productIdentifiers)
但是當我嘗試動態地創建標識符,我得到一個錯誤:
var strIdentifiers = [String]()
for subscription in subscriptions {
strIdentifiers.append(subscription["id"] as! String)
}
let productIdentifiers: Set<ProductIdentifier> = strIdentifiers
Globals.store = IAPHelper(productIds: productIdentifiers)
Globals.store.requestProducts{success, products in
if success {
.......
}
}
我得到這個錯誤:
Cannot assign value of type '[String]' to type 'Set<ProductIdentifier>' (aka 'Set<String>')
任何指導將不勝感激
如何定義'subscriptions'? –
let subscriptions = pages [「subscriptions」] as! [NSDictionary] – oppositemind