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 195 views
1 answer 167 views
1 answer 185 views
1 answer 141 views
141 views asked Apr 30, 2025 by avibootz
1 answer 166 views
2 answers 167 views
1 answer 149 views
...