I’m looking for some sample code to track UITouches with a CFDictionary. Unfortunately the apple-docs don’t have a complete example.
I’m currently using NSMutable array, but I want to store the complete UITouch object, so to get the timestamp as well.
NSMutableArray *touchArray_val;
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
touchArray_val = [[NSMutableArray alloc] init];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
for(UITouch *t in touches){
CGPoint currentPoint = [t locationInView:self];
[touchArray_val addObject:[NSValue valueWithCGPoint: currentPoint]];
}
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"%i",[touchArray count]);
for(NSValue *val in touchArray_val){
NSLog(@"%@",val);
}
}
The pointer of the UITouch will not change over the lifetime of the touch. You can create an NSValue from the pointer.