A basic understanding of threads is good enough for you to start using them in your applications. However, once you start using them, there's a good chance that they suddenly become confusing again. If this happens to you, don't worry; threading is not easy. Now let's look at an example of threaded code:
var someBoolean = false DispatchQueue(label: "MutateSomeBoolean").async { // perform some work here for i in 0..<100 { continue } someBoolean = true } print(someBoolean)
The preceding snippet demonstrates how you could mutate a variable after performing a task that is too slow to execute on the main thread. In the preceding code, an instance of DispatchQueue is created, and it's given a label. This ...