I'm trying to make an array(shopImages3) with arrays which hold 3 objects by using a temporary array(tempArray). The big array which contains all the strings to start with is shopImages.
The big array contains 6 strings at this moment. This means it comes 2 times in the
" if((i == 2) || (i == 5) || (i == 8) || (i == 11) || (i == 14) || (i == 18)) "
statement. This works fine. But the NSLogs show the arrays are null.
How can I fill the arrays correctly?
2014-08-28 14:01:52.575 Jump Game[3622:60b] this is temp array (null)
2014-08-28 14:01:52.575 Jump Game[3622:60b] this is shopimages array (null)
2014-08-28 14:01:52.576 Jump Game[3622:60b] this is temp array (null)
2014-08-28 14:01:52.576 Jump Game[3622:60b] this is shopimages array (null)
THE CODE STARTS FROM HERE
@interface ShopCollectionViewController ()
{
NSArray *shopImages;
NSMutableArray *shopImages3;
NSMutableArray *tempArray;
}
........
for ( int i = 0; i < [shopImages count]; i++)
{
[tempArray addObject: shopImages[i]];
if((i == 2) || (i == 5) || (i == 8) || (i == 11) || (i == 14) || (i == 18))
{
NSLog(@"this is temp array %@", tempArray);
[shopImages3 addObject:tempArray];
NSLog(@"this is shopimages array %@", shopImages3);
[tempArray removeAllObjects];
}
}