iphone - Objective-c IN APP PURCHASE 实现时出现错误

标签 iphone objective-c xcode in-app-purchase

我正在实现应用内购买,但我不是一位经验丰富的开发人员。 我正在使用我在这里找到的布兰特特洛伊教程: 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

有人可以帮助我吗?

最佳答案

答案就像 kperryua 所说的那样,但只是为了说清楚:

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

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

@end

它应该工作得很好。

关于iphone - Objective-c IN APP PURCHASE 实现时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8763985/

相关文章:

ios - 注销推送通知

ios - 将 UIImageview 添加到 subview 后无法单击 UIAlertView 中的按钮

ios - 如何在没有链接器命令失败的情况下在核心数据中添加实体

Swift - 将委托(delegate)连接到自定义 Xib 单元

ios - UIPickerView 有两行

iphone - 使用 Storyboard iOS 5 的 RSS Feed iPhone

iphone - 如何从方法内显示 UIActivityIndi​​catorView 并开始为其设置动画

ios - 缩小和适合 MapKit 中所有注释的最佳方法是什么

iPhone 拉动以刷新移动图标位置

swift - xcode 8.3.3 是否运行 swift 3.2