Search code examples
swiftstorekitnsset

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?


Solution

  • I believe you want this code:

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