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
For multiple functions use this. This is very helpful to use animations or Activity loader for static functions or any UI Update.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.9) {
// Call your function 1
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
// Call your function 2
}
}
For example - Use a animation before a tableView reloads. Or any other UI update after the animation.
*// Start your amination*
self.startAnimation()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.9) {
*// The animation will execute depending on the delay time*
self.stopAnimation()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
*// Now update your view*
self.fetchData()
self.updateUI()
}
}