I'm trying to differentiate between two (or more) UITouch objects on the iPhone. Specifically, I'd like to know the order in which the touches occurred.
For instance, in my -touchesBegan:withEvent: method I get an NSSet of UITouch objects. Now I can find out how many touches there are, but, which object represents which finger?
I notice the timestamp property on UITouch - is this what I'm looking for? I see how that would be useful to obtaining the last or first touch - providing the touches don't mutate...
Therein lies my problem. I can use the timestamp to single out the latest touch, but then the touch that occurred first moves, and IT becomes the latest touch...
At the end of this exercise, I'd like to be able to implement the "pinch" gesture to zoom in or out, etc.
Any help would be greatly appreciated, thanks.
Each finger gets one UITouch object, and the same object is given to you again and again. Simply remember the pointers to set of initial UITouch objects, and do a pointer comparison to keep track of fingers.
From Apple's reference docs:
A touch object is persistent for a given finger during a sequence, and UIKit mutates it as it tracks the finger throughout it. The touch attributes that change are the phase of the touch, its location in a view, its previous location, and its timestamp. Event-handling code evaluates these attributes to determine how to respond to the event.