我正在嘗試將應用內購買添加到我的iPhone應用。但是當我運行我的應用程序或嘗試購買商品我的應用程序崩潰,並顯示下一個錯誤:應用內購買崩潰
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found). (gdb)
我把StoreKit
代碼在NSObject
類,看看代碼波紋管。
StorePurchase.h
:
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
@interface StorePurchase : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver> {
}
- (void)loadStore;
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions;
- (void)purchase;
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response;
@end
StorePurchase.m
:
#import "StorePurchase.h"
@implementation StorePurchase
- (void)loadStore {
if ([SKPaymentQueue canMakePayments]) {
NSLog(@"Parental-controls are disabled");
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"testding2"]];
request.delegate = self;
[request start];
}
else {
NSLog(@"Parental-controls are enabled");
}
}
- (void)purchase {
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"testding2"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
SKProduct *validProduct = nil;
int count = [response.products count];
if (count > 0) {
validProduct = [response.products objectAtIndex:0];
NSLog(@"Products found, joepie!!!");
} else if (!validProduct) {
NSLog(@"No products available");
}
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
NSLog(@"An error encounterd");
}
else {
NSLog(@"Cancelled!");
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
}
}
}
@end
我調用該方法 「loadStore」 是這樣的:
StorePurchase *classStorePurchase = [[StorePurchase alloc] init];
[classStorePurchase loadStore];
我希望有人能幫助我這個...
是的,在StorePurchase.h文件。當我嘗試購買一個物品時,我會彈出購買它,但是當我取消並再次嘗試時,它大多會崩潰... – Flappy 2011-06-08 13:14:24
如果打開Objective-C異常的Break,它應顯示它正在崩潰的行。 ..運行 - >在Objective-c異常中停止。讓我知道什麼線路崩潰.... – 2011-06-08 13:15:50
它停在這裏:如果([SKPaymentQueue canMakePayments]){ – Flappy 2011-06-08 13:22:14