2012-01-06 65 views
2

我正在實施應用程序內購買,我不是一個非常有經驗的開發人員。 我使用布蘭特特洛伊教程我發現這裏: Tutorial錯誤objective-c在應用程序購買實施

我在loadStore方法實現的錯誤: 發送「InAppPurchaseManager * const的__strong」到不兼容的類型「ID」

// 
// InAppPurchaseManager.h 
// 

#import <Foundation/Foundation.h> 
#import <StoreKit/StoreKit.h> 

@interface InAppPurchaseManager : NSObject <SKProductsRequestDelegate> 
{ 
    SKProduct *proUpgradeProduct; 
    SKProductsRequest *productsRequest; 
} 

// public methods 
- (void)loadStore; 
- (BOOL)canMakePurchases; 
- (void)purchaseProUpgrade; 

@end 

--- 

#import "InAppPurchaseManager.h" 

#define kInAppPurchaseProUpgradeProductId @"com.user.app.product" 

@implementation InAppPurchaseManager 

- (void)loadStore 
{ 
    // restarts any purchases if they were interrupted last time the app was open 

    [[SKPaymentQueue defaultQueue] addTransactionObserver: self]; 
ERROR HERE: Sending 'InAppPurchaseManager *const __strong' to parameter of incompatible type 'id<SKPaymentTransactionObserver>' 

    // get the product description (defined in early sections) 
    [self requestProUpgradeProductData]; 
} 

@end 
的參數

任何人都可以幫助我嗎?

回答

3

答案就像kperryua說,只是要清楚:

@interface InAppPurchaseManager : NSObject <SKProductsRequestDelegate,SKPaymentTransactionObserver> 
{ 
SKProduct *proUpgradeProduct; 
SKProductsRequest *productsRequest; 
} 

// public methods 
- (void)loadStore; 
- (BOOL)canMakePurchases; 
- (void)purchaseProUpgrade; 

@end 

它應該只是罰款。

+0

Ooooooh NO。我已經做到了。現在它工作。謝謝。 – Byteros 2012-01-07 00:38:12

+0

歡迎您! @Byteros – 2012-01-07 23:59:56

0

您需要聲明InAppPurchaseManager符合SKPaymentTransactionObserver協議。

+0

OPS ...是的,它現在工作得很好。 – Byteros 2012-01-09 18:58:21