so I have a mutable array that holds several circles which are UIViews.
right now I have my touches began method setup like this.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
for (Circle *circle in playerOneCircles)
{
if ([circle.layer.presentationLayer hitTest:touchLocation])
{
[circle playerTap:nil];
break;
}
}
}
this works fine. but it gives problems with overlapping views.
I want other UIviews to also respond to the touchesbegan method (that would then trigger other methods). but if 2 objects would overlap then my touchesbegan would trigger the wrong method.
so I would like to define multiple UITouches that only respond to certain objects instead of anyObject. how would I have to define the UITouch to only work with objects from my mutable array?
EDIT
Added comments to answer your comment to explain the code.
You would implement containsPoint for a Circle something like this…