How to set timer to go to next view controller

I would like my app to change view controllers after certain period of time. How to do this?

Replies

You asked a very similar question in another thread (and did not tell if the solution proposed worked).

So it is a similar solution here: use DispatchQueue.main.asyncAfter

let delay : Double = 5.0    // 5 seconds here
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
    // Code to go to other controller, either segue, or VC instantiation
}
  • Well it didn't really work, but thanks for new solution. How do I tell from which to which view controller should it go?

Add a Comment

How do I tell from which to which view controller should it go

As I said, you can instantiate the VC (as you did in another post) or you can perform segue that you can define in IB.