How to pause execution for 5 seconds in Swift

1 Answer

0 votes
import Foundation

print("Execution paused for 5 seconds...")

Thread.sleep(forTimeInterval: 5) // Pause execution for 5 seconds

print("Resuming execution.")



/*
run:

Execution paused for 5 seconds...
Resuming execution.

*/

 



answered Apr 30, 2025 by avibootz

Related questions

2 answers 197 views
1 answer 169 views
1 answer 188 views
1 answer 144 views
144 views asked Apr 30, 2025 by avibootz
1 answer 170 views
2 answers 170 views
1 answer 152 views
...