2010-11-16 70 views
0

运行我下面的代码它给我的设备上这种反应....关于iPhone的错误问题

- (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.0​​28 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] *由于未捕获的异常'NSInvalid ArgumentException的”,原因是: ' - [NSCFString localizedTitle]:无法识别的选择发送到实例0x114990'

为什么会出现上述错误...

请指导我了...

回答

8

因为invalidProductIdentifiers只包含一列NSString s,而不是SKProduct s。

See the StoreKit documentation.

NSLog(@"Invalid products:%@",[myInvalidProducts objectAtIndex:i]); 
+0

hi..can你可以告诉我我需要怎么展示它.. – user198725878 2010-11-16 09:52:39

+0

你需要展示什么?由于productIdentifiers无效,因此只能显示productIdentifier,而不能显示本地化信息。看到我编辑的答案。 – 2010-11-16 10:00:17

+0

@joseph;感谢您的回复...我问你什么是你可以请显示什么是我的代码中的错误..它不显示产品...自返回0计数 – user198725878 2010-11-16 10:12:30

2

,难道你不想叫 “localizedTitle” 上NSCFString而不是产品的?