In:
if (colorArray != nil) {
a = arc4random()% [colorArray count];
}
int y = [[colorArray objectAtIndex:a] integerValue];
what is most likely happening is that [colorArray count]
has not the value you expect it to have, so that arc4random
only returns 0 (or a limited set of values).
If you add an NSLog trace just before calculating the value for a
, you can assess the value for [colorArray count]
.