Restore Purchases Array?

So, I’m building a storybook app that will have many different stories for sale within the app (as in-app purchases).  Per Apple’s requirements, I’ve integrated a “Restore Purchases” option into the app.  I’ve got everything working but I still have one outstanding issue.

 

As far as I know, when store.restore() is called, there is no way to know how many purchases will be restored.  Could be 0, could be 1, could be 12.  When a product is restored, I’m downloading a .TAR file of the story (using network.download()) and I then kick off a function that un-tars the story and places it in the appropriate directory.

 

When the restore is first fired, I want to display an activity indicator and then once all of the stories are downloaded and un-tarred, I want to cancel the activity indicator and then reload the scene…which will reload the scrollview that contains all of the story icons to reflect that the story has been purchased and is available to be read.  Unfortunately, since store.restore() and my un-tar function all run asynchronously, I have no way to “listen” to when the downloads are all done.  The restore and un-tar functions all have onComplete listeners, but due to the asynchronous nature of the code, I can’t seem to figure out how to count the number of restores needing to be done and then tracking them.  I tried incrementing a variable during restore and then decrementing it during un-tar…and assuming completion when var = 0, but the asynchronosity (is that a word?) of it all causes it to behave strangely and doesn’t really work.

 

Whew…so, all that said, is there a way to know how many products will be restored when store.restore() is called?  Is there an array of purchased products?  In other words, how many products have previously been purchased?  

 

Second question - if I can’t figure this out, I was thinking that instead of reloading the whole scene, I could just update the various objects in the scrollview as the specific stories are un-tarred.  To do that though, I’d need to replace the existing story icon in the scrollview with a different icon that displays “purchased” on top of the original icon.  I’m not sure if an active scrollview item can have it’s image replaced?  Or, if I do need to recreate the entire scrollview.

 

I hope this all makes sense.  Would appreciate any insight.  

 

Brian