Question: I have this animation:

```
override func viewDidLoad() {
        super.viewDidLoad()
_ = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(self.callingFunction), userInfo: nil, repeats: true)
}

@objc func callingFunction(){
        let image0:UIImage = UIImage(named: "next0.png")!
        let image1:UIImage = UIImage(named: "next1.png")!
        let image2:UIImage = UIImage(named: "next2.png")!
        let image3:UIImage = UIImage(named: "next3.png")!
        let image4:UIImage = UIImage(named: "next4.png")!
        let image5:UIImage = UIImage(named: "next5.png")!
        let image6:UIImage = UIImage(named: "next6.png")!
        let image7:UIImage = UIImage(named: "next7.png")!

        nextButton.setImage(image0, for: .normal)
        nextButton.imageView!.animationImages = [image0, image1, image2, image3, image4, image5, image6, image7]
        nextButton.imageView!.animationDuration = 1.0
        nextButton.imageView!.startAnimating()
    }

```

I need to repeat this animation in every 15 seconds. But this animation starts after 15 seconds and next execute every 1 second.

Answer: 
You have to call function by using timer. Set timeInterval to 15 seconds. 

```
callingFunction()
timer = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(self.callingFunction), userInfo: nil, repeats: true)

func callingFunction(){
      //Execute your code
      let image0:UIImage = UIImage(named: "next0.png")!
let image1:UIImage = UIImage(named: "next1.png")!
let image2:UIImage = UIImage(named: "next2.png")!
let image3:UIImage = UIImage(named: "next3.png")!
let image4:UIImage = UIImage(named: "next4.png")!
let image5:UIImage = UIImage(named: "next5.png")!
let image6:UIImage = UIImage(named: "next6.png")!
let image7:UIImage = UIImage(named: "next7.png")!

nextButton.setImage(image0, for: .normal)
nextButton.imageView!.animationImages = [image0, image1, image2, image3, image4, image5, image6, image7]
nextButton.imageView!.animationDuration = 1.0
nextButton.imageView!.animationRepeatCount = 1
nextButton.imageView!.startAnimating()
}

```
You can use a timer:

```
let timer = Timer.scheduledTimer(withTimeInterval: 15, repeats: true) {
     [weak self] (timer) in
     self?.nextButton.imageView?.startAnimating()
}

```

To stop it:

```
timer.invalidate()

```