Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Swift 创建一个桌面应用程序,我需要stop在 5 秒后传递一个布尔值。我该怎么做呢?
stop
您可以使用 asyncAfter 创建异步延迟。在 5.0 秒后,你可以做你想做的事。
var stop: Bool = false DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) { // runs after 5.0 seconds // pass your stop boolean here }