Where do I attach the StoreKit delegate and observer in a Cocos2d App?
Posted
by Jeff B
on Stack Overflow
See other posts from Stack Overflow
or by Jeff B
Published on 2010-05-08T04:46:44Z
Indexed on
2010/05/08
4:58 UTC
Read the original article
Hit count: 260
I have figured out how all of the StoreKit stuff works and have actually tested working code... however, I have a problem.
I made my "store" layer/scene the SKProductsRequestDelegate
. Is this the correct thing to do? I get the initial product info like so:
SKProductsRequest *productRequest = [[SKProductsRequest alloc] initWithProductIdentifiers: productIDs];
[productRequest setDelegate: self];
[productRequest start];
The problem is that if I transition to a new scene when a request is in progress, the current layer is retained by the productRequest. This means that touches on my new scene/layer are handled by both the new layer and the old layer.
I could cancel the productRequest when leaving the scene, but:
- I do not know if it is in progress at that point.
- I cannot release it because it may or may not have been released by the request delegates.
There has got to be a better way to do this. I could make the delegate a class external to the current layer, but then I do not know how to easily update the layer with the product information when the handler is called.
© Stack Overflow or respective owner