I have this block of code:
DispatchQueue.main.asyncAfter(deadline: .now() + (delay * Double(isDelayAccounted.hashValue)) + extraDelay) {
self.isShootingOnHold = false
self.shoot()
self.shootingEngine = Timer.scheduledTimer(timeInterval: (Double(60)/Double(self.ratePerMinute)), target: self, selector: #selector(ShootingEnemy.shoot), userInfo: nil, repeats: true)
}
现在,我希望能够停止这个线程的执行。如何停止它的执行呢?例如,当过了3秒后,我决定不再让它继续执行,因此我想要停止它。