I need to access a random element from IBOutletCollection
array. I have 4 letter imageViews that needs to be dragged on to another imageView and change the image depending on how many were dragged. Im testing with 2 at the moment. I have this but it doesn't seem to take random but a particular one of the 4.
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UIImageView *letter in letterA)
{
for (UIImageView *letter1 in letterA)
{
if (CGRectIntersectsRect(letter.frame ,answerA.frame))
{
UIImage *Pic1 = [UIImage imageNamed:@"number1"];
[correctCounterA setImage:Pic1];
letter.userInteractionEnabled=NO;
letter.hidden=YES;
}
else if (CGRectIntersectsRect(letter1.frame, answerA.frame)) //CGRectIntersectsRect(letter.frame, answerA.frame))
{
UIImage *Pic2 = [UIImage imageNamed:@"number2"];
[correctCounterA setImage:Pic2];
}
}
}
}