Adam Rush

@Adam9Rush

11 January, 2022

Sometimes, you might hit the requirement to perform some code execution after a delay, and you can do this by using Swift GCD (Grand Central Dispatch) system to execute some code after a set delay.

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
    // Code to be executed
}

In this code, you’re creating a block execution to happen using the main thread after a delay of 1 second from now.

Sponsor

Subscribe for curated Swift content for free

- weekly delivered.