2010-11-16 54 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而不是產品的?