How to track NSTouches?
I'm building a game and this is the first time where I've needed more than one touch to work. I've noticed that there appears to be no rhyme or reason to the indexing of touches in the NSSet. It can even flip while both touches are still active. Can anyone explain this? And can anyone explain how I can keep track of each touch and it's movements (since asking for the touch at an index may not return th开发者_如何学运维e one you thought was there)?
NSSet is explicitly not ordered, if they had intended the touches to be ordered they would have made it an NSArray instead.
See Apple's Event Handling Guide for iOS for instructions and sample code on tracking multiple touches; in short, they recommend using a CFDictionaryRef keyed on the addresses of each touch object to store whichever properties you are interested in.
精彩评论