I'm still wrapping my head around the migration away from NSError. In Xcode 8 Beta 3, here's how I detected a StoreKit error that was not a cancel:
// "transaction" is an SKPaymentTransaction
switch transaction.transactionState {
case .failed:
if let code = transaction.error?.code, code != SKErrorCode.paymentCancelled.rawValue {
// handle the error...The above does not compile because the "error" property is no longer an NSError, which means it has no "code" property. I haven't been able to figure out how to migrate this code appropriately. Any help would be appreciated.
The b4 release notes have this example:
catch let error as CocoaError where error.code == .fileReadNoSuchFileError {
print("No such file: \(error.url)")
}So, the expression you want is, I guess, something like:
(transaction.error as? SKError).code == .paymentCancelled
with suitable optional binding to make sure it's the right kind of error.