SKProduct productIdentifier无法识别的选择器发送到实例

时间:2013-03-04 20:01:07

标签: iphone in-app-purchase

我正试图在我的应用程序中购买应用程序中的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'

1 个答案:

答案 0 :(得分:0)

SKProduct *product = [[InAppGameIAHelper sharedHelper].products objectAtIndex:0];行真的给你一个SKProduct

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