dispatch_after - GCD in Swift?

前端 未结 25 2389
心在旅途
心在旅途 2020-11-21 06:07

I\'ve gone through the iBook from Apple, and couldn\'t find any definition of it:

Can someone explain the structure of dispatch_after?

d         


        
25条回答
  •  离开以前
    2020-11-21 06:40

    In Swift 4

    Use this snippet:

        let delayInSec = 1.0
        DispatchQueue.main.asyncAfter(deadline: .now() + delayInSec) {
           // code here
           print("It works")
        }
    

提交回复
热议问题