I'm creating a desktop app with Swift and I need to pass a stop
boolean after 5 seconds. How do I do this?
Asked
Active
Viewed 192 times
-4

Marge Daniels
- 38
- 6
1 Answers
1
You can use asyncAfter to create an async delay. After the 5.0 seconds you can do what you want.
var stop: Bool = false
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) { // runs after 5.0 seconds
// pass your stop boolean here
}

Sean Stayns
- 4,082
- 5
- 25
- 35