0

我正在尝试在我的应用程序中的应用程序购买中在 iPhone 中实现。

我在按钮上有一个 IBAction 来购买迷你游戏:

-(IBAction) buyGame:(id)sender {

    SKProduct *product = [[InAppGameIAHelper sharedHelper].products objectAtIndex:0];

    NSLog(@"Buying %@...", product.productIdentifier);

    [[InAppGameIAHelper sharedHelper] buyProductIdentifier:product.productIdentifier];
    self.hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
    _hud.labelText = @"Buying...";

    [self performSelector:@selector(timeout:) withObject:nil afterDelay:60*5];
}

[InAppGameIAHelper sharedHelper] 允许从商店加载项目,并加载产品列表。

[InAppGameIAHelper sharedHelper].products 是一个 NSArray :

products (
    "com.me.myapp"
)

当我点击购买按钮时,我的应用程序崩溃并出现以下错误:

2013-03-04 20:24:50.314 isam[11922:c07] -[__NSCFConstantString productIdentifier]: unrecognized selector sent to instance 0x22ae30
2013-03-04 20:24:50.318 isam[11922:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString productIdentifier]: unrecognized selector sent to instance 0x22ae30'
4

1 回答 1

0

SKProduct *product = [[InAppGameIAHelper sharedHelper].products objectAtIndex:0];条线实际上是给你一个SKProduct吗?

我的猜测是您的代码在打印之前就崩溃了,NSLog因为您的方法以某种方式返回了NSString.

于 2013-03-04T21:54:33.583 回答