我分類爲SKPaymentTransaction(例如MutableSKPaymentTransaction),覆蓋只讀參數。已經有一個可變的SKPaymentTransaction,您可以使用,或者您可以用類似的方式覆蓋SKPayment。
實施例:
在頭文件(MutableSKPaymentTransaction.h)文件
#import <StoreKit/StoreKit.h>
@interface MutableSKPaymentTransaction : SKPaymentTransaction
@property (readwrite, copy, nonatomic) NSError * error;
@property (readwrite, copy, nonatomic) SKPayment * payment;
@property (readwrite, copy, nonatomic) NSString * transactionIdentifier;
@property (readwrite, copy, nonatomic) NSDate * transactionDate;
@property (readwrite, copy, nonatomic) NSArray * downloads;
@property (readwrite, copy, nonatomic) SKPaymentTransaction *originalTransaction;
@property (assign, nonatomic) SKPaymentTransactionState transactionState;
@end
和在方法文件(MutableSKPaymentTransaction.m):
#import "MutableSKPaymentTransaction.h"
@implementation MutableSKPaymentTransaction
// readonly override
@synthesize error = _error;
@synthesize payment = _payment;
@synthesize transactionIdentifier = _transactionIdentifier;
@synthesize transactionDate = _transactionDate;
@synthesize downloads = _downloads;
@synthesize originalTransaction = _originalTransaction;
@synthesize transactionState = _transactionState;
@end