title: touchesBegan and responders in iOS
body: <p>How can I add an event recognizer to an object?</p>
  
  <p>I have the following code:</p>
  
  <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  {
  NSLog(@"touches happened");
  
  
      UITouch *touch = [[event allTouches] anyObject];
      CGPoint touchLocation = [touch locationInView:self.mainView];
  
      for (UIView *view in self.mainView.subviews)
      {
          if ([view isKindOfClass:[ViewController class]] &amp;&amp;
              CGRectContainsPoint(view.frame, touchLocation))
          {
              NSLog(@"my Touch Happened");
              UIImageView *tmp = (UIImageView *)view;
              if (selectedItem != tmp)
                  [self setSelected:tmp];
  
          }
      }
  }
  </code></pre>
  
  <p>My goal is, if my image is touched, not tapped or long pressed but touched at all, to do the logic starting at the <code>NSLog(@"found whats being touched");</code></p>
  
  <p>I;ve use UIGestureRecognizers before and you add them to whatever you want.</p>
  
  <p>[self.SomeImage addGestureRecognizer:rotate];</p>
  
  <p>But how do I tell my objects to listen to this code? </p>
  
  <p>I wanna know if the touched area is the same area that another object exists in? that is, if the user is trying to pan an item. I can handle the pan. But the second before the pan is the touch. How Do I go about finding that touch and the object that is associated with that!</p>