Concurrency and Grand Central Dispatch in Swift (GCD)
Published in
6 min readApr 7, 2019
GCD allows you to multitask using threads in Swift.
Prerequisites:
- Closures
- Adding the following to use Playground:
- Adding the following to use a Command-line Application:
The problem
We need to prioritise what the user can see, their interactions and their user experiences.
If you put a network call in viewDidLoad() before some layout setup, you will have to wait for the network call to execute before the view will load. That’s incredibly bad, both for the user (who might think that the App has crashed) and any business you might happen to be working for at that particular time. Users do tend to uninstall Apps that are not responsive (and sometimes even leave a nasty…