I've got a singleton (StoreManager) to help me manage my In-App Purchases, and it has a property called productArray, which is set like so:
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
self.productArray = response.products;
}
In my store's view controller, I have this code:
-(void)setupPrices
{
if ([[StoreManager sharedStoreManager] productArray]) {
[productArray objectAtIndex:2]...
}
It was working fine for a while, but now I get SIGABRT: index 2 beyond bounds of empty array, so clearly my if statement has passed as true, even though the method that sets the value hasn't been called yet. I thought this was weird so I tried some code and it seems if I do
NSArray *array;
NSLog (@"%u", array.count);
I get bad access and if I do
NSArray *array;
if (array)
NSLog(@"Array is not nil");
The statement passes. I'm sure I'm missing something here. How do I check if my array has been set?