gpt4 book ai didi

ios - IAP 导致 SIGABRT

转载 作者:行者123 更新时间:2023-12-01 16:59:31 25 4
gpt4 key购买 nike

这是我第一次使用应用程序购买,我不确定我做错了什么。 SKProductsRequest运行良好,但在尝试购买时,应用程序崩溃并显示 SIGABRT

应用委托(delegate)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
MKStoreObserver *observer = [[MKStoreObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
return YES;
}

ViewController.m
- (void)viewDidLoad
{
if ([SKPaymentQueue canMakePayments])
{
[self requestProductData];
}
else {
}
[super viewDidLoad];
}

- (IBAction)buyButton:(id)sender
{
SKPayment *payment = [SKPayment paymentWithProduct:kMyFeatureIdentifier];
[[SKPaymentQueue defaultQueue] addPayment:payment];

//When this button is touched the app crashes
}

- (void)requestProductData
{
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:kMyFeatureIdentifier]];

request.delegate = self;
[request start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *myProduct = response.products;

if (myProduct.count) {

SKProduct *thisProduct = [myProduct objectAtIndex:0];


productTitle.text = [NSString stringWithFormat:@"%@", thisProduct.localizedTitle];

productPrice.text = [NSString stringWithFormat:@"For only $%@", thisProduct.price];

}
}

MKStoreObserver.m
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions)
{

switch ( transaction.transactionState )

{

case SKPaymentTransactionStatePurchased:

[ self completeTransaction: transaction ];

break;

case SKPaymentTransactionStateFailed:

[ self failedTransaction: transaction ];

break;

case SKPaymentTransactionStateRestored:

[ self restoreTransaction: transaction ];

break;

default:

break;
}
}
}

- (void)completeTransaction: (SKPaymentTransaction *)transaction
{
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}

- (void)failedTransaction: (SKPaymentTransaction *)transaction
{
if (transaction.error.code != SKErrorPaymentCancelled)
{
// Optionally, display an error here.
}
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}

- (void)restoreTransaction: (SKPaymentTransaction *)transaction
{
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}

当按下购买按钮时是应用程序崩溃的时间

这?

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Fri Sep 16 06:56:50 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i386-apple-darwin

--target=arm-apple-darwin".tty /dev/ttys000 target remote-mobile /tmp/.XcodeGDBRemote-4242-20 Switching to remote-macosx protocol mem 0x1000 0x3fffffff cache mem 0x40000000 0xffffffff none mem 0x00000000 0x0fff none [Switching to process 7171 thread 0x1c03] [Switching to process 7171 thread 0x1c03] sharedlibrary apply-load-rules all 2011-12-12 21:39:11.082 inAppTest[171:707] -[__NSCFSet productIdentifier]: unrecognized selector sent to instance 0x134e70 2011-12-12 21:39:11.091 inAppTest[171:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet productIdentifier]: unrecognized selector sent to instance 0x134e70'

*** First throw call stack: (0x344298bf 0x346791e5 0x3442cacb 0x3442b945 0x34386680 0x3251b2ed 0x2c9d 0x34383435 0x377ed9eb 0x377ed9a7 0x377ed985 0x377ed6f5 0x377ee02d 0x377ec50f 0x377ebf01 0x377d24ed 0x377d1d2d 0x30c04df3 0x343fd553 0x343fd4f5 0x343fc343 0x3437f4dd 0x3437f3a5 0x30c03fcd 0x37800743 0x2a41 0x29d8) terminate called throwing an exception(gdb)

最佳答案

你在哪里定义kMyFeatureIdentifier ?如果尚未定义,似乎很可能会导致此错误。

关于ios - IAP 导致 SIGABRT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8484399/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com