I'm trying to understand UIEvent, UITouch Object reusing So I trying test but result makes me confused
this is my code
class CustomView: UIView {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("==========================")
print("Event Object : \(Unmanaged.passUnretained(event!).toOpaque())")
for (index, touch) in touches.enumerated() {
print("\(index)'s, UITouch Object : \(Unmanaged.passUnretained(touch).toOpaque())")
}
print("==========================")
}
}
class ViewController: UIViewController {
@IBOutlet weak var skyBlueView: CustomView!
var previousTouch:UITouch?
var currentTouch:UITouch?
override func viewDidLoad() {
super.viewDidLoad()
self.view.isMultipleTouchEnabled = true
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("==========================")
print("Event Object : \(Unmanaged.passUnretained(event!).toOpaque())")
for (index, touch) in touches.enumerated() {
print("\(index)'s, UITouch Object : \(Unmanaged.passUnretained(touch).toOpaque()) Tap Count: \(touch.tapCount)")
}
print("==========================")
}
}
I expect that touch objects of same coordinates are same
but result wasn't. This are
my results
Here is my questions
When UIEvent Object is released? UIEvent is still reused
Tap counts are increasing on same coordinates, but objects are different how Tap counts is shared between UITouch Objects
- 9 touches occurred but only 4 UITouch objects (0x00007f9881c086f0, 0x00007f9881d04000, 0x00007f9881e02650, 0x00007f988500c5c0) are reusing? how does it works?