试图在 swift 中向类签名添加协议 [英] Trying to add a protocol to a Class signature in swift

查看:43
本文介绍了试图在 swift 中向类签名添加协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试快速创建应用内购买.在我的班级签名中,我有以下内容:

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 中向类签名添加协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆