First I created a randomDelay value using arc4random
Then I would like to add the randomDelay value to the DispatchQueue to create a random Time Delay Variable
Here is my code:
func animation1() {
UIView.animate(withDuration: 1, animations: {
// various code
}, completion: { (true) in
//delay calling the function by the randomDelay value of '0' to '2' seconds
let randomDelay = arc4random_uniform(3)
DispatchQueue.main.asyncAfter(deadline: .now() + randomDelay) { // the randomDelay value throws an unresolved identifier 'randomDelay' error
self.showAnimation2() // Go to the next function
}
})
}
Thanks