注意:我正在开发Mac,而不是iOS!

- (void)recordTransaction:(SKPaymentTransaction *)transaction
{
    if ([transaction.payment.productIdentifier isEqualToString:kInAppProIdentifier])
    {
        [[NSUserDefaults standardUserDefaults] setValue:transaction.transactionReceipt     forKey:@"proUpgradeTransactionReceipt" ];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

我从编译器收到此错误:
error: property 'transactionReceipt' not found on object of type 'SKPaymentTransaction *'; did you mean 'transactionDate'? [3]

另外,我在reference for the transactionReceipt class中找不到SKPaymentTransaction属性! (即使此页面包含对“收据”的一些引用,也没有transactionReceipt属性)。

但是the documentation说它应该存在!



这有什么问题?

最佳答案

我对StoreKit进行了类转储,以了解是否存在此方法。这是标题:

@interface SKPaymentTransaction : NSObject
{
    id _internal;
}

- (id)init;
- (id)initWithDictionary:(id)arg1;
- (id)initWithPayment:(id)arg1;
- (void)dealloc;
@property(readonly) NSError *error;
@property(readonly) SKPaymentTransaction *originalTransaction;
@property(readonly) SKPayment *payment;
@property(readonly) NSDate *transactionDate;
@property(readonly) NSString *transactionIdentifier;
- (id)transactionReceipt;
@property(readonly) long long transactionState;
- (BOOL)canMergeWithTransaction:(id)arg1;
- (id)matchingIdentifier;
- (BOOL)mergeWithTransaction:(id)arg1;
- (id)_transactionIdentifier;

@end

您可以将此方法与[transaction transactionReceipt]一起使用(并得到警告)。 Apple可能会或可能不会考虑使用私有(private)方法并拒绝您的申请;但是,出于测试目的,它在那里。

10-07 22:08