Skip to content

Instantly share code, notes, and snippets.

@heestand-xyz
Created October 15, 2018 15:13
Show Gist options
  • Save heestand-xyz/72946d926ea2599e36dd5c576edf7cb8 to your computer and use it in GitHub Desktop.
Save heestand-xyz/72946d926ea2599e36dd5c576edf7cb8 to your computer and use it in GitHub Desktop.
Touches
var allTouches: [UITouch] = []
func add(_ touches: Set<UITouch>) -> [UITouch] {
for newTouch in touches {
var exist = false
for oldTouch in allTouches {
if oldTouch == newTouch {
exist = true
break
}
}
if !exist {
allTouches.append(newTouch)
}
}
return allTouches
}
func remove(_ touches: Set<UITouch>) -> [UITouch] {
for newTouch in touches {
for (i, oldTouch) in allTouches.enumerated() {
if oldTouch == newTouch {
allTouches.remove(at: i)
break
}
}
}
return allTouches
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment