/fun-with-gcd

This project is a showcase for most concepts and tasks, that we can perfrom using Grand Central Dispatch. I have prepared being an iOS Expert for iOS Ukraine conference #1

Primary LanguageSwiftMIT LicenseMIT

Fun with Grand Central Dispatch

This project is a showcase for most concepts and tasks, that we can perfrom using Grand Central Dispatch. I have prepared it being for my iOS Expert role at iOS Ukraine conference #1, that took place in September 2020.

It consists of a series of tasks, from basic to more complex, that illustrate how something works or how a certain problem is usually solved.

How to use it

Open ViewController.swift and uncomment a task you are interested in. Run!

0️⃣ Task 0

Illustrates how synchronous execution works

1️⃣ Task 1

Illustrates how asynchronous execution works

2️⃣ Task 2

Illustrates how concurrent and serial queues work

3️⃣ Task 3

Illustrates how the system handles queues with different quality of service

4️⃣ Task 4

Illustrates how the system handles queues with different quality of service comparing to main queue

5️⃣ Task 5

Illustrates how the system handles queues with different quality of service

6️⃣ Task 6

Illustrates concurrent access to a property and a way to protect a property

7️⃣ Task 7

Illustrates how concurrent execution of a not protected section of code can crash an app in a place where everything looks fine

8️⃣ Task 8

Illustrates how to synchronize an asynchronous API

9️⃣ Task 9

Shows how to create own very simple asynchronous interface

🔟 Task 10

Shows how to create an asynchronous interface in a way, that is used extnsively in Apple products

1️⃣1️⃣ Task 11

Know how to deadlock (so you won't do it)

1️⃣2️⃣ Task 12

Illustrates how to execute a completion after several asynchronous tasks are finished (like updating UI after getting responses on several API requests)

Further Reading

There is an excellent book on GCD: 'Pro Multythreading and Memory Management for iOS and OSX with ARC, Grand Central Dispatch and Blocks' by Kazuki Sakamoto and Tomohiko Furumoto.