Search code examples
swiftprotocolsstorekit

Trying to add a protocol to a Class signature in 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{

However, I get an error message: type "ViewController" does not conform to protocol: SKPaymentTransactionObserver

I've read this: https://developer.apple.com/library/prerelease/mac/documentation/Swift/Conceptual/BuildingCocoaApps/WritingSwiftClassesWithObjective-CBehavior.html and Conform to protocol in ViewController, in Swift

The SKSoreProductViewControllerDelegate works fine. What am I missing, please?


Solution

  • Have you implemented the required methods in your class?

    paymentQueue:updatedTransactions: and paymentQueue:updatedDownloads: are required methods and you will get a warning if they are not implemented.