title: touchesBegan & touchesMoved
body: <p>So here's a weird question. I have a UIImageView that responds to <code>touchesMoved:</code> &amp; <code>touchesBegan:</code>, it works perfectly. The main thing I'm having an issue with is if you put your finger down on say image1 and then with that finger still down on image1 you would press image2 with your other finger. </p>
  
  <p>In turn this would fire image1 again. Dont want that to happen. I want to be able to use Multi Touch when pushing both images at the same time and not firing them over and over. There must be something I have to add to stop that from happening. </p>
  
  <p>Code:</p>
  
  <pre><code>    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  {
      NSSet *allTouches = [event allTouches]; 
      for (UITouch *touch in allTouches) 
      { 
          CGPoint location = [touch locationInView:touch.view];
          if(CGRectContainsPoint(image1.frame, location) &amp;&amp; lastButton != image1) {
              //Play Sound
              NSString *path = [[NSBundle mainBundle] pathForResource:@"sound1" 
                                                               ofType:@"wav"];
              SystemSoundID soundID;
              AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
                                               , &amp;soundID);
              AudioServicesPlaySystemSound (soundID); 
              //
              lastButton = image1;
          }
          if(CGRectContainsPoint(image2.frame, location) &amp;&amp; lastButton != image2) {
              //Play Sound
              NSString *path = [[NSBundle mainBundle] pathForResource:@"sound2" 
                                                               ofType:@"wav"];
              SystemSoundID soundID;
              AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
                                               , &amp;soundID);
              AudioServicesPlaySystemSound (soundID); 
              //
              lastButton = image2;
          }
  
      }
  </code></pre>
  
  <p>And for the touchesMoved:</p>
  
  <pre><code>-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  {
      UITouch *touch = [[event allTouches] anyObject];
      CGPoint location = [touch locationInView:touch.view];
          if(CGRectContainsPoint(image1.frame, location) &amp;&amp; lastButton != image1) {
              //Play Sound
              NSString *path = [[NSBundle mainBundle] pathForResource:@"sound1" 
                                                               ofType:@"wav"];
              SystemSoundID soundID;
              AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
                                               , &amp;soundID);
              AudioServicesPlaySystemSound (soundID); 
              //
              lastButton = image1;
          }
          if(CGRectContainsPoint(image2.frame, location) &amp;&amp; lastButton != image2) {
              //Play Sound
              NSString *path = [[NSBundle mainBundle] pathForResource:@"sound2" 
                                                               ofType:@"wav"];
              SystemSoundID soundID;
              AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
                                               , &amp;soundID);
              AudioServicesPlaySystemSound (soundID); 
              //
              lastButton = image2;
          }
  
      }
  </code></pre>
  
  <p>Lastly here are the finals: </p>
  
  <pre><code>- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
      lastButton = nil;
  }
  
  - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
      [self touchesEnded:touches withEvent:event];
  }
  </code></pre>
  
  <p>So I just need to make it so if I'm holding down one of the images and then press another and release it again and push it again that it stops firing the first image I am pressing down on.</p>