dispatch_after - GCD in Swift?

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

    To execute a funtion or code after a delay use the next method

    DispatchQueue.main.asyncAfter(deadline: .now() + 'secondsOfDelay') {
            your code here...
        }
    

    Example - In this example the funtion getShowMovies will be executed after 1 second

    DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
            self.getShowMovies()
        }
    

提交回复
热议问题