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 166 views
1 answer 138 views
1 answer 160 views
1 answer 117 views
117 views asked Apr 30, 2025 by avibootz
1 answer 138 views
2 answers 142 views
1 answer 125 views
...