After some digging around i found a neat solution to this, with a lot of help from this guy (http://www.codedojo.com/?p=1030).
In the end it was about understanding how iOS handles its touch events. What was not initially clear to me is that when a touch begins a UITouch object is created and then as long as that finger is down (even if you are moving it around the screen) iOS uses the same UITouch object but updates the properties of the object based on your action.
This was the basis for my implementation and using the idea from codedojo i implemented a simple touchManager that maintains an Array of UITouch objects and updates this array whenever a finger is added or removed from screen.
So at any point in time you have a data structure that maintains all the UITouch objects using which you can get the finger traces for multiple touches. And the big up is, you can use this data struct anywhere in your code to do what is necessary pretty easily.
@interface TouchStateManager : NSObject{
NSMutableArray *touches;
}
@property(nonatomic , assign , readwrite)NSMutableArray *touches;
-(int)addTouch:(UITouch *)_touch;
-(int)getActiveTouchCount;
-(int)getFingerIdForTouch:(UITouch *)_touch;
@implementation GETouchStateManager
@synthesize touches;
-(int)getFingerIdForTouch:(UITouch *)_touch{
if(self.touches == NULL){
self.touches = [[NSMutableArray alloc] initWithCapacity:MAX_TOUCHES];
}
if([self.touches containsObject:_touch]){
return [self.touches indexOfObject:_touch];
}
else
return -1;
}
-(int)addTouch:(UITouch *)_touch{
if([self.touches count] == 0){
[self.touches addObject:_touch];
return [self getActiveTouchCount];
}
else{
if(![self.touches containsObject:_touch]){
[self.touches addObject:_touch];
return [self getActiveTouchCount];
}
}
return -1;
}
-(int)getActiveTouchCount{
DLog(@"Count : %d" , [touches count]);
return [touches count];
}
This worked pretty well for me, im able to track upto 11 fingers in the iPad!