问题描述
我正在尝试快速创建应用内购买.在我的班级签名中,我有以下内容:
I'm trying to create an in-app purchase in swift. In my class signature, I have the following:
class ViewController: UIViewController, UITextFieldDelegate, UIAlertViewDelegate,
SKStoreProductViewControllerDelegate, SKPaymentTransactionObserver{
但是,我收到一条错误消息:类型ViewController"不符合协议:SKPaymentTransactionObserver
However, I get an error message: type "ViewController" does not conform to protocol: SKPaymentTransactionObserver
我读过这个:https://developer.apple.com/library/prerelease/mac/documentation/Swift/Conceptual/BuildingCocoaApps/WritingSwiftClassesWithObjective-CBehavior.html 和 符合 ViewController 中的协议,在 Swift 中
SKSoreProductViewControllerDelegate 工作正常.请问我遗漏了什么?
The SKSoreProductViewControllerDelegate works fine. What am I missing, please?
推荐答案
您是否在类中实现了所需的方法?
Have you implemented the required methods in your class?
paymentQueue:updatedTransactions:
和 paymentQueue:updatedDownloads:
是必需的方法,如果未实现,您将收到警告.
paymentQueue:updatedTransactions:
and paymentQueue:updatedDownloads:
are required methods and you will get a warning if they are not implemented.
这篇关于试图在 swift 中向类签名添加协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!