dispatch_after - GCD in Swift?

前端 未结 25 2426
心在旅途
心在旅途 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:51

    Now more than syntactic sugar for asynchronous dispatches in Grand Central Dispatch (GCD) in Swift.

    add Podfile

    pod 'AsyncSwift'
    

    Then,you can use it like this.

    let seconds = 3.0
    Async.main(after: seconds) {
    print("Is called after 3 seconds")
    }.background(after: 6.0) {
    print("At least 3.0 seconds after previous block, and 6.0 after Async code is called")
    }
    

提交回复
热议问题