.h
@property (nonatomic, strong) NSMutableDictionary * products; //not synthesized in .m
.m
- (void)productsRequest:(SKProduct
It's not IAPProduct *product= NSMutableDictionary[NSArray.productIdentifier];
The type of skProduct
is SKProduct
, not NSArray
. The fast enumeration for (SKProduct * skProduct in skProducts)
loops through all elements in skProducts
as SKProduct
.
It's (to some extent) like using a loop with a counter doing:
//for (SKProduct * skProduct in skProducts)
for (int i=0; i<skProducts.count; i++)
{
SKProduct *skProduct = skProduct[i];
IAPProduct * product = _products[skProduct.productIdentifier];
product.skProduct = skProduct;
product.availableForPurchase = YES;
}
You are having trouble understanding this line:
IAPProduct * product = _products[skProduct.productIdentifier];
Lets break it down:
NSString *key = skProduct.productIdentifier;
IAPProduct * product = _products[key];
The 2nd line is modern syntax for:
IAProduct * product = [_products objectForKey:key];
This is the normal way to lookup a value in a dictionary for a given key.