In my homescreen, I have a startGame button that when pressed should set off an animation (sender.pulsate()) and then also change viewController:

```
 @IBAction func newGamePressed(_ sender: UIButton) {
        currentScore = 0
        timeRemaining = 60
        visualTime = "01:00"

        sender.pulsate()

        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateViewController(withIdentifier: "firstLevel")
        self.present(viewController, animated: false, completion: nil)

    }

```

However, the new viewController appears instantly rather than waiting for the Pulsate animation to occur (the pulsate animation does work).

I know this has something to do with the code not being read top down, but what can I add to tell xcode to run one before the other?

Thank you!

ps. this is the pulsate code if its relevant:

```
   func pulsate() {

        let pulse = CASpringAnimation(keyPath: "transform.scale")
        pulse.duration = 0.6
        pulse.fromValue = 0.95
        pulse.toValue = 1.0
        pulse.autoreverses = true
        pulse.repeatCount = 2
        pulse.initialVelocity = 0.5
        pulse.damping = 1.0

        layer.add(pulse, forKey: nil)

    }

```