所以我試圖在我的精靈套件遊戲的應用程序購買實現,我在斯威夫特工作。我知道我需要在SKProductsRequestDelegate
和SKPaymentTransactionObserver
協議添加到我的GameScene
類,爲了做到這一點,但是當我加入他們,我得到的錯誤:Swift:無法將SKProductsRequestDelegate協議添加到GameScene類中?
Type 'GameScene' does not conform to protocol 'SKProductsRequestDelegate'
和SKPaymentTransactionObserver
類似的錯誤。
我進口StoreKit
這裏是我的代碼:
import SpriteKit
import AVFoundation
import StoreKit
class GameScene: SKScene, SKPhysicsContactDelegate, SKProductsRequestDelegate, SKPaymentTransactionObserver {
我在做什麼錯?
聲稱一致性是不夠的,你實際上必須實現協議所需的方法。我認爲SKProductsRequestDelegate有一個子協議。但總而言之,你確定GameScene是應該處理商店交易的類嗎?我更喜歡單獨的類處理商店交易,沒有別的。 – gnasher729
哪裏可以找到協議的方法? – skyguy
查看標記爲_Required_ [here]的方法(https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKProductsRequestDelegate/#//apple_ref/occ/intfm/SKProductsRequestDelegate/productsRequest:didReceiveResponse :) and [這裏](https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKPaymentTransactionObserver_Protocol/) – 0x141E