kri*_*orn 4 protocols storekit swift
我正在尝试在swift中创建一个应用内购买.在我的班级签名中,我有以下内容:
class ViewController: UIViewController, UITextFieldDelegate, UIAlertViewDelegate,
SKStoreProductViewControllerDelegate, SKPaymentTransactionObserver{
Run Code Online (Sandbox Code Playgroud)
但是,我收到一条错误消息:类型"ViewController"不符合协议:SKPaymentTransactionObserver
我读过这个:https://developer.apple.com/library/prerelease/mac/documentation/Swift/Conceptual/BuildingCocoaApps/WritingSwiftClassesWithObjective-CBehavior.html并在ViewController中符合协议,在Swift中
SKSoreProductViewControllerDelegate工作正常.我错过了什么?
您是否在课堂上实施了所需的方法?
paymentQueue:updatedTransactions:并且paymentQueue:updatedDownloads:是必需的方法,如果没有实现,您将收到警告.
SKPaymentTransactionProtocol 有这些方法:
func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!)
@optional func paymentQueue(queue: SKPaymentQueue!, removedTransactions transactions: [AnyObject]!)
@optional func paymentQueue(queue: SKPaymentQueue!, restoreCompletedTransactionsFailedWithError error: NSError!)
@optional func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!)
@optional func paymentQueue(queue: SKPaymentQueue!, updatedDownloads downloads: [AnyObject]!)
Run Code Online (Sandbox Code Playgroud)
第一个是您的类必须实现的必需方法,以符合协议.将它添加到ViewController,错误将消失.
class ViewController: UIViewController, UITextFieldDelegate, UIAlertViewDelegate,
SKStoreProductViewControllerDelegate, SKPaymentTransactionObserver{
func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!){/*...*/}
/*...*/
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2267 次 |
| 最近记录: |