2012-01-06 52 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