Unresolved Identifier - SKErrorPaymentCancelled [duplicate]

醉酒当歌 提交于 2019-12-03 17:35:33

问题


I updated to the latest version of Xcode 7.3 with the release of iOS 9.3 & OSX 10.11.4 (inclusive of Swift 2.2) yesterday.

When I build my app I get an error stating Use of unresolved identifier 'SKErrorPaymentCancelled' which I use to check if the user has cancelled a payment. I don't do anything special with it, just log it (as seen below).

private func failedTransaction(transaction: SKPaymentTransaction) {
    print("failedTransaction...")
    if transaction.error!.code == SKErrorPaymentCancelled {
        print("Transaction Cancelled: \(transaction.error!.localizedDescription)")
    }
    else {
        print("Transaction Error: \(transaction.error!.localizedDescription)")
    }
    SKPaymentQueue.defaultQueue().finishTransaction(transaction)
}

I can't find anything in the Swift 2.2 changelog that states anything within StoreKit was changed. This worked fine before I updated.

Is anyone else seeing this issue?


回答1:


The constant SKErrorPaymentCancelled has been removed from the SDK as of iOS 9.3. Instead, use the SKErrorCode.PaymentCancelled enum.

For more information, see the StoreKit Changes for Swift page of the iOS 9.3 API Diffs and my canonical Q&A post Use of unresolved identifier when using StoreKit constants with iOS 9.3/Xcode 7.3.



来源:https://stackoverflow.com/questions/36156724/unresolved-identifier-skerrorpaymentcancelled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!