I’m engaged on an iOS app the place I’ve an AnyArtboardEvent technique that pushes snapshots into my undo/redo stack.
Right here’s a simplified model of it:
func AnyArtboardEvent(mergedImaged: UIImage = UIImage()) {
self.undoRedo?.Add(worth: self.SlotViewsToCollection(mergedImage: mergedImaged))
self.UpdateControllerForActiveSlot()
}
The Add technique in my UndoRedo class simply appends values to a group (no recursion there).
func Add(worth: SlotViewCollection) {
var pointerTemp: Int = self.pointer
pointerTemp = pointerTemp + 1
self.pointer = pointerTemp
self.CheckValueAtIndex(worth)
self.EnsureCollectionSize()
}
Problem is that when person finishes interacting with a slider, I name AnyArtboardEvent contained in the .ended part of my contact occasion handler:
if let touchEvent = occasion.allTouches?.first {
swap touchEvent.part {
case .ended:
self.isAnyThingChange = true
self.AnyArtboardEvent() // <-- known as right here
self.CurrentActiveSlot?.TextLabel?.InitCaLayer(parentView: self)
default:
break
}
}
However after debugging:
When the slider interplay ends, AnyArtboardEvent known as thrice.
The primary name is predicted, however the second and third calls occur instantly afterward (with out me explicitly calling them).
I added a symbolic breakpoint and confirmed that every one three calls originate from this .ended block.
I additionally checked the InitCaLayer technique (which provides a border CAShapeLayer), however it doesn’t name AnyArtboardEvent.
To this point, I couldn’t discover something in my code that may trigger AnyArtboardEvent to run a number of instances.
Is it attainable that touchesEnded / .ended part is firing a number of instances for the slider gesture?
Or may including layers (CAShapeLayer) not directly set off structure passes that fireplace the contact occasion handler once more?
How can I guarantee AnyArtboardEvent known as solely as soon as per slider interplay?