well there are many solutions:
you could change the if statement like this:
Code:
if ((i % 16 == 0) && i) { ... }
since in the first iteration i is equal to 0, the if will evaluate to false.
Or you could check the size of currArray instead
Code:
if (currArray.count == 16) { ... }
and I'm sure there are many other ways.
By the way I just noticed these 2 lines on your code:
Code:
tempObj = [[ItemPic alloc]init];
tempObj = [[self pics] objectAtIndex:i];
What are you doing here is bad, you are leaking memory, because you are allocating an ItemPic object in the first line, and in the second line you are assigning tempObj to another object, losing the reference to the ItemPic object created on the line before, thus you will never be able to release it. So just remove the first line, since it is completely useless. And after that remove also those lines:
Code:
[tempObj release];
tempObj=nil;
Since you have not allocated tempObj, you do not have to release it.