Search code examples
iosswiftsprite-kitstorekit

Reference to generic type 'Set' requires arguments in <...> & Generic Parameter 'element' could not be inferred


I was working on In-App Purchases and came across two errors.

The first one is private let productIdentifiers: Set It comes up with the error "Reference to generic type 'Set' requires arguments in <...>"

The second error in my code is private var purchasedProductIdentifiers = Set() It comes up with the error "Generic parameter 'Element' could not be inferred"

Here is most of my code near the two errors:

public class IAPHelper : NSObject  {

private let productIdentifiers: Set
private var purchasedProductIdentifiers = Set()

private var productsRequest: SKProductsRequest?
private var productsRequestCompletionHandler: ProductsRequestCompletionHandler?

 static let IAPHelperPurchaseNotification =     "IAPHelperPurchaseNotification"

public init(productIds: Set<ProductIdentifier>) {
self.productIdentifiers = productIds


super.init()
 }
}

Help would be nice!!

EDIT: I now get the error '>' is not a postfix unary operator when I change the second error to private var purchasedProductIdentifiers = Set<ProductIdentifier> = Set()


Solution

  • private let productIdentifiers : Set<ProductIdentifier>
    private var purchasedProductIdentifiers : Set<ProductIdentifier> = Set()