。H
@property (nonatomic, strong) NSMutableDictionary * products; //not synthesized in .m
.m
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSLog(@"Loaded list of products...");
_productsRequest = nil;
NSArray * skProducts = response.products;
for (SKProduct * skProduct in skProducts)
{
IAPProduct * product = _products[skProduct.productIdentifier];
product.skProduct = skProduct;
product.availableForPurchase = YES;
}
for (NSString * invalidProductIdentifier in response.invalidProductIdentifiers)
{
IAPProduct * product = _products[invalidProductIdentifier];
product.availableForPurchase = NO;
NSLog(@"Invalid product identifier, removing: %@", invalidProductIdentifier);
}
NSMutableArray * availableProducts = [NSMutableArray array];
for (IAPProduct * product in _products.allValues) {
if (product.availableForPurchase) {
[availableProducts addObject:product];
}
}
_completionHandler(YES, availableProducts);
_completionHandler = nil;
}
我在下面的行中遇到问题:
IAPProduct * product = _products[skProduct.productIdentifier];
我在想我们正在设置类型IAPProduct *product= NSMutableDictionary[NSArray.productIdentifier];
我以为数组只有元素(objectAtIndex
)?为什么会有一个点 (.) 和 productIdentifier?
还