swift 2 syntax changes

I have transfered to swift 2 and i can't work out what the error is can you help.


var request: SKProductsRequest = SKProductsRequest(productIdentifiers: productID as Set<NSObject>)

and this one


func paymentQueue (queue: SKPaymentQueue!, removedTransactions, transactions: [AnyObject]!) {

print("remove trans");

}

If you're going to ask for help with error messages, it would be helpful if you can post the actual error message too. Anyway, try:


var request: SKProductsRequest = SKProductsRequest(productIdentifiers: Set<NSObject>)


func paymentQueue (queue: SKPaymentQueue!, removedTransactions transactions: [AnyObject]!) {


You can look this sort of thing up yourself, using the the documentation in Xcode or at the Apple developer web site: just search for the class/protocol, and look for the method in the class/protocol-specific document. The syntax is right there.

QuinceyMorris: your first example looks wrong to me - you're using a type (Set<NSObject>) as an argument.


I would assume the issue with the first example, depending on the type of 'productID', would be the 'as'. If it's an upcast (subclass cast as superclass) then it's superfluous; if it's a downcast (superclass as subclass) then it's not guaranteed to work, so the result will be optional, and you should use 'as?' or 'as!' (seems like 'as!' in this case, but be sure).

Yep, you're right. I didn't pay attention to the first half of the line.


Given that it's 'productID' rather than 'productIDs', perhaps what's really wanted is:


var request: SKProductsRequest = SKProductsRequest(productIdentifiers: [productID])


leaving it to the compiler to construct a Set from the array literal. But we'd really need to see the error message.

swift 2 syntax changes
 
 
Q