swift3 - Accessing code in Swift 3 Error -
new in xcode 8 beta 4, nserror
bridged swift error
protocol type. affects storekit when dealing failed skpaymenttransaction
s. ought check sure error didn't occur because transaction cancelled know whether or not show error message user. examining error's code
. error
instead of nserror
, there no code
defined. haven't been able figure out how error code error
.
this worked in previous version of swift 3:
func failedtransaction(_ transaction: skpaymenttransaction) { if let transactionerror = transaction.error { if transactionerror.code != skerrorcode.paymentcancelled.rawvalue { //show error user } } ... }
now error
error
not nserror
, code
not member.
casting skerror
seems working me in xcode 8 , swift 3...
guard let error = transaction.error as? skerror else {return} switch error.code { // https://developer.apple.com/reference/storekit/skerror.code case .unknown: break case .paymentcancelled: break case .clientinvalid: break case .paymentinvalid: break case .paymentnotallowed: break case .cloudservicenetworkconnectionfailed: break case .cloudservicepermissiondenied: break case .storeproductnotavailable: break }
no need rawvalue
.
Comments
Post a Comment