Iphone – How to assign a unique key to a UITouch throughout it’s lifecycle

iphone

I need to associate a unique key to a UITouch instance throughout it's lifecycle -Began, Moved, Ended, Cancelled. I've been printing NSLog on a key for each touch and noticed to my suprise that each touch does not generate a unique key if the key is generated as follows:

for (UITouch *touch in touches) {

// …

NSValue *key = [NSValue valueWithPointer:touch];

// …

}

How can I make each touch generate a unique key?

Thanks.

Best Solution

Actually, I found out the root cause of my need to do this. I was not handling a mult-tap situation where the tap count exceeded 1. The actual issue is handling tap counts.

So, all touches are indeed unique. It is just that a touch can in fact contain multiple taps within a give touch.

More here (Apple Developer Forum URL)

Related Question