Delay Function in DinoDefense

As I am working through the 2D IOS & tvOS Games for Swift 2.2 on the DinoDefense chapters (chapter 20) I am struggling to understand the actual code of the dinosaur delay function in Utilities. Can someone explain how that works? I didn’t see it explained in the book.

Also, how would you stop/cancel the code from running?

Example, I have 10 dinosaurs in a wave and 3 have already been let out in the dino opening screen.
Lets say I change to a main menu screen using a button. I have another button on the main menu that will bring me back to the dino opening screen.
Ideally the other 7 dinosaurs should not come out from the pervious wave.
When I touch the screen a new wave of 10 dinosaurs should start up again when you come back to the dino opening screen (that is what I want).
As of right now I get 17 coming out.