ios - Swift3 Storekit - Cast string array to Set<ProductIdentifier> -


i trying implement storekit in app purchases. following hardcoded value works fine:

my globals struct:

static var productidentifiers: set<productidentifier> = ["com.app.myiap"] static var store = iaphelper(productids: globals.productidentifiers) 

in function:

globals.store = iaphelper(productids: productidentifiers) 

but when try create identifiers dynamically, error:

var stridentifiers = [string]() 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 {         .......     } } 

i error:

cannot assign value of type '[string]' type 'set<productidentifier>' (aka 'set<string>') 

any guidance appreciated

subscription["id"] returns array of type [productidentifier].

you can not cast array type as! productidentifier.

either:

change cast as! [productidentifier]

or

check place set subscription["id"]. maybe set array accidentally.

i assume later, "id" should productidentifier, not array.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -