我正在实施IN APP购买,我不是一个非常有经验的开发人员。 我正在使用我在这里找到的brant troy教程: Tutorial
我在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
任何人都可以帮助我吗?
答案 0 :(得分:3)
答案就像kperryua所说,但只是为了说清楚:
@interface InAppPurchaseManager : NSObject <SKProductsRequestDelegate,SKPaymentTransactionObserver>
{
SKProduct *proUpgradeProduct;
SKProductsRequest *productsRequest;
}
// public methods
- (void)loadStore;
- (BOOL)canMakePurchases;
- (void)purchaseProUpgrade;
@end
它应该可以正常工作。
答案 1 :(得分:0)
您需要声明InAppPurchaseManager
符合SKPaymentTransactionObserver
协议。