Schuey999 Schuey999 - 1 year ago 104
Swift Question

How to create a delay in Swift?

I want to pause my app at a certain in point. In other words, I want my app to execute the code, but then at a certain point, pause for 4 seconds, and then continue on with the rest of the code. How can I do this?

I am using Swift.

Answer Source

You will probably want to use NSTimer instead of a sleep, since the former won't lock up your program (if you are doing this from a UI thread).

But, if you need it:

... {

This uses the sleep function from UNIX.