您好,我正在尝试为 ios 5 和新的 ios 6 设置应用程序购买。我被告知我的“paymentWithProductIdentifier 已弃用”,我想知道是否有人可以告诉我如何修改我的代码,我有点困惑。
SKProduct *selectedProduct = <#from the products response list#>;
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
我看到人们提出以下建议,但我从我的代码中不确定“产品响应列表将是什么”。我以为会,但事实并非如此。
[response.products];
这是我的方法代码,如果有人能告诉我要改变什么,将不胜感激,谢谢!
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
SKProduct *validProduct = nil;
int count = [response.products count];
NSLog (@"count for in app purchases is %d", count);
if (count>0) {
validProduct = [response.products objectAtIndex:0];
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"appUpdate1"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment]; // <-- KA CHING!
NSLog (@"payment proccessed I think");
}
}