Question regarding iPhone error
when i run my below code it gives this response on my device....
- (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] initWithP开发者_开发知识库roductIdentifiers: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] View is loaded
2010-11-16 14:14:46.164 InAppPurchaseTesting[7357:307] Requesting
2010-11-16 14:14:46.196 InAppPurchaseTesting[7357:307] can make payments
2010-11-16 14:14:52.135 InAppPurchaseTesting[7357:307] Did recieve response
2010-11-16 14:14:52.146 InAppPurchaseTesting[7357:307] Response count is 0
2010-11-16 14:14:52.152 InAppPurchaseTesting[7357:307] Invalid response count is 1
2010-11-16 14:14:52.160 InAppPurchaseTesting[7357:307] -[NSCFString localizedTitle]: unrecognized selector sent to instance 0x114990
2010-11-16 14:14:52.181 InAppPurchaseTesting[7357:307] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString localizedTitle]: unrecognized selector sent to instance 0x114990'
why the above error occurs...
please guide me out...
Because invalidProductIdentifiers
only contains an array of NSString
s, not SKProduct
s.
See the StoreKit documentation.
NSLog(@"Invalid products:%@",[myInvalidProducts objectAtIndex:i]);
Aren't you trying to call "localizedTitle" on NSCFString instead of a Product?
精彩评论