Questions tagged «libdispatch»

6
在Swift 3,Swift 4及更高版本中,我如何使用dispatch_sync,dispatch_async,dispatch_after等?
我在Swift 2.x(甚至1.x)项目中有很多代码,如下所示: // Move to a background thread to do some long running work dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { let image = self.loadOrGenerateAnImage() // Bounce back to the main thread to update the UI dispatch_async(dispatch_get_main_queue()) { self.imageView.image = image } } 或类似这样的东西来延迟执行: dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.5 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) { print("test") } 或Grand Central …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.