当我运行我的下面的代码时,它会在我的设备上给出这个响应....
- (void) requestProductData
{
//
NSString *str = [[NSString alloc] initWithFormat:@"com.mycompany.inapppurchasetesting.productid"];//Same as the Product Id displayed in Itunes Connect//"];
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:str]];
request.delegate = self;
[request start];
//
//NSSet *productIDs = [NSSet setWithObjects:@"com.mycompany.inapppurchasetesting.productid", nil];
//SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:productIDs];
//request.delegate = self;
NSLog(@"Requesting");
//[request start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *myProduct = response.products;
NSArray *myInvalidProducts = response.invalidProductIdentifiers;
NSLog(@"Did recieve response");
NSLog(@"Response count is %d",response.products.count);
NSLog(@"Invalid response count is %d",response.invalidProductIdentifiers.count);
for (int i = 0; i<myProduct.count; i++)
{
NSLog(@"t:%@",[[myProduct objectAtIndex:i] localizedTitle]);
}
for(int i = 0; i < myInvalidProducts.count; ++i)
{
NSLog(@"Invalid products:%@",[[myInvalidProducts objectAtIndex:i] localizedTitle]);
}
// populate UI
[request autorelease];
}
2010-11-16 14:14:46.028 InAppPurchaseTesting [7357:307]加载视图
2010-11-16 14:14:46.164 InAppPurchaseTesting [7357:307]请求
2010-11-16 14:14:46.196 InAppPurchaseTesting [7357:307]可以付款
2010-11-16 14:14:52.135 InAppPurchaseTesting [7357:307]收到回复
2010-11-16 14:14:52.146 InAppPurchaseTesting [7357:307]响应次数为0
2010-11-16 14:14:52.152 InAppPurchaseTesting [7357:307]无效的响应计数为1
2010-11-16 14:14:52.160 InAppPurchaseTesting [7357:307] - [NSCFString localizedTitle]:无法识别的选择器发送到实例0x114990
2010-11-16 14:14:52.181 InAppPurchaseTesting [7357:307] * 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [NSCFString localizedTitle]:无法识别的选择器发送到实例0x114990'
为什么会出现上述错误......
请指导我......
答案 0 :(得分:8)
因为invalidProductIdentifiers
只包含NSString
s的数组,而不是SKProduct
s。
See the StoreKit documentation.
NSLog(@"Invalid products:%@",[myInvalidProducts objectAtIndex:i]);
答案 1 :(得分:2)
你是不是想在NSCFString上调用“localizedTitle”而不是产品?