cocoa touch - Why a Set of UITouch? -
i curious why uiresponder method returns set of uitouch objects opposed array
override func touchesmoved(touches: set<uitouch>, withevent event: uievent?)
i can't quite wrap head around benefits or purpose behind it. hoping explain happening in background , how end set of uitouch. example if drag 2 fingers across screen wouldn't array of uitouch objects?
most of can speculate why uikit reports set rather array.
here's guess: emphasizes touches aren't in particular order , might not in same order 1 event next. since there's no subscript operator set
or nsset
, it's harder make mistake of storing index (0, 1, 2, etc.) of touch use when processing later event.
it may implementation detail. uikit reports touch events app @ 60 hz (on devices), synchronized screen refresh. if hardware supports reporting touch events more 60 hz, uikit needs coalesce multiple events same touch. coalescing occurs automatically, in sense, if uikit stores updated touches set instead of array.
Comments
Post a Comment