I have code similar to this
if (count == 0)
{
[array1 addObject:@"No Items"];
}
else
{
int x;
for (x = 0;x <= count; x++)
{
[array1 addObject:[itemsArray objectAtIndex:x];
NSLog(@"%@",array1);
}
}
itemsArray has numbers in it (0-40). My expected result is:
- 1
- 2
- 3
- ...
However it actually does:
- 1
- 1,2
- 1,2,3
- 1,2,3,4
- 1,2,3,4,5
- ...
Why does this happen? If possible, I'd also like to ask for an example to use fast enumeration for this situation (if it suits for this).
Thanks in advance.
addObjectsFromArray:instead if looping through itemsArray.