I have three gestures: 2-finger tap, 3-finger tap, and 4-finger tap. I need to get coordinates accordingly.
I have tried the following to get the coordinated of 2 fingers tap but app keeps crashing:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *twoTouch = [touches allObjects];
UITouch *tOne = [twoTouch objectAtIndex:0];
UITouch *tTwo = [twoTouch objectAtIndex:1];
CGPoint firstTouch = [tOne locationInView:[tOne view]];
CGPoint secondTouch = [tTwo locationInView:[tTwo view]];
NSLog(@"point one: %@", firstTouch);
NSLog(@"point two: %@", secondTouch);
[twoTouch release];
}
First of all, your application is not checking if there actually are two touches. If you tap the screen with one finger you will get one touch in the "touches".
Try something like this.
if(touches.count > 1 && touches.count < 3)
{
// Your code for two touches.
}
Otherwise, the part where your program crashes is the [twoTouch objectAtIndex:1] because objectAtIndex:1 doesn't exist.
(I know this is a really old question but I answered it anyways.)