krisacorn krisacorn - 3 years ago 138
Swift Question

How do I replicate NSSet with init in swift

I'm trying to replicate this Objective C line in swift:

SKProductsRequest *request = [[SKProductsRequest alloc]
initWithProductIdentifiers:[NSSet setWithObject:self.productID]];

The apple docs read that the swift version is :

init(productIdentifiers productIdentifiers: NSSet!)

So my attempt is

let productID:NSSet = NSSet("somevalue");
let request:SKProductsRequest = SKProductsRequest(productIdentifiers:init(productID));

Can anyone see what I'm doing wrong?

Answer Source

I believe you want this code:

let productID = NSSet(object: "somevalue");
let request = SKProductsRequest(productIdentifiers: productID);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download