Hi there!
I'm trying to get multitouch working in my app but when there's more than one finger on the screen the app crashes when trying to access them. In touches moved, if number of touches is higher than 1 (so there are at least two fingers in the screen) the app tries to access the two fingers, but throws an NSException error. Here's the code and after it the error:
Code:
Code:
// In touchesMoved event
NSLog(@"Touches:%d",[[event allTouches] count]);
if ([[event allTouches] count] > 1) {
for(UITouch *t in [touches allObjects])
{
NSLog(@"Luke, I'm your father!");
}
UITouch *t2 = [[touches allObjects] objectAtIndex:1];
CGPoint touchPos2 = [t2 locationInView:t2.view];
(...irrelevant code...)
}
And here's what I get in the console:
Code:
2010-02-23 10:04:23.694 provaObjectes3D[1909:207] Touches:2
2010-02-23 10:04:24.106 provaObjectes3D[1909:207] Luke, I'm your father!
2010-02-23 10:04:24.130 provaObjectes3D[1909:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (1) beyond bounds (1)'
2010-02-23 10:04:24.157 provaObjectes3D[1909:207] Stack: (
853417245,
845594132,
852966195,
852966099,
871671569,
871826727,
13227,
818194628,
818192276,
818173840,
818172052,
834382224,
853165355,
853163039,
834376564,
817839152,
817832496,
9127,
9060
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
kill
So seems that just the first object position is accessible... However, count says that there are two objects... Argh, it have no sense! :S
Any help please? Thanks in advance!